You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2018/03/22 08:16:09 UTC
incubator-weex git commit: [Weex-260][iOS] switch supports setting
color close #1076
Repository: incubator-weex
Updated Branches:
refs/heads/master 40c6c191a -> f27bf04c4
[Weex-260][iOS] switch supports setting color
close #1076
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/f27bf04c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/f27bf04c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/f27bf04c
Branch: refs/heads/master
Commit: f27bf04c4e50b37ce1f5e86d152f3f725fa9b733
Parents: 40c6c19
Author: Tw93 <tw...@qq.com>
Authored: Tue Mar 20 15:23:09 2018 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Mar 22 16:15:05 2018 +0800
----------------------------------------------------------------------
.../Sources/Component/WXSwitchComponent.m | 49 ++++++++++++++++++++
1 file changed, 49 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f27bf04c/ios/sdk/WeexSDK/Sources/Component/WXSwitchComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXSwitchComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXSwitchComponent.m
index 2ab57a9..f5f9ce2 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXSwitchComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXSwitchComponent.m
@@ -36,6 +36,16 @@
@property (nonatomic, assign) BOOL checked;
@property (nonatomic, assign) BOOL disabled;
+//Background color when the switch is turned on.
+@property (nonatomic, strong) UIColor *onTintColor;
+
+
+//Color of the foreground switch grip.
+@property (nonatomic, strong) UIColor *thumbTintColor;
+
+//Border color and background color on Android when the switch is turned off
+@property (nonatomic, strong) UIColor *tintColor;
+
@end
@implementation WXSwitchComponent
@@ -46,6 +56,18 @@
_checked = attributes[@"checked"] ? [WXConvert BOOL:attributes[@"checked"]] : NO;
_disabled = attributes[@"disabled"] ? [WXConvert BOOL:attributes[@"disabled"]] : NO;
+ if(attributes[@"onTintColor"]){
+ _onTintColor = [WXConvert UIColor:attributes[@"onTintColor"]];
+ }
+
+ if(attributes[@"thumbTintColor"]){
+ _thumbTintColor = [WXConvert UIColor:attributes[@"thumbTintColor"]];
+ }
+
+ if(attributes[@"tintColor"]){
+ _tintColor = [WXConvert UIColor:attributes[@"tintColor"]];
+ }
+
self.cssNode->style.dimensions[CSS_WIDTH] = 51;
self.cssNode->style.dimensions[CSS_HEIGHT] = 31;
}
@@ -64,6 +86,18 @@
[_switchView setOn:_checked animated:YES];
[_switchView setEnabled:!_disabled];
[_switchView addTarget:self action:@selector(checkChanged) forControlEvents:UIControlEventValueChanged];
+
+ if(_onTintColor){
+ _switchView.onTintColor = _onTintColor;
+ }
+
+ if(_tintColor){
+ _switchView.tintColor = _tintColor;
+ }
+
+ if(_thumbTintColor){
+ _switchView.thumbTintColor = _thumbTintColor;
+ }
}
- (void)addEvent:(NSString *)eventName
@@ -90,6 +124,21 @@
_disabled = [WXConvert BOOL:attributes[@"disabled"]];
[_switchView setEnabled:!_disabled];
}
+
+ if(attributes[@"onTintColor"]){
+ _onTintColor = [WXConvert UIColor:attributes[@"onTintColor"]];
+ _switchView.onTintColor = _onTintColor;
+ }
+
+ if(attributes[@"thumbTintColor"]){
+ _thumbTintColor = [WXConvert UIColor:attributes[@"thumbTintColor"]];
+ _switchView.thumbTintColor = _thumbTintColor;
+ }
+
+ if(attributes[@"tintColor"]){
+ _tintColor = [WXConvert UIColor:attributes[@"tintColor"]];
+ _switchView.tintColor = _tintColor;
+ }
}
- (void)checkChanged