/**
* 皮肤管理工具类
*/
@interface ZinkSkinManager : NSObject
/**
* 设置该属性,即可修改当前皮肤
*/
@property (assign, nonatomic) SkinType skinType;
@end
@interface UIView (ZinkSkin)
/**
* 将各个皮肤对应的颜色传入数组
*/
- (void)zinkSetSkinWithBackgroundColors:(NSArray<UIColor *> *)array;
@end
UIView *view;
[view zinkSetSkinWithBackgroundColors:@[[UIColor whiteColor], [UIColor darkGrayColor]]];
@interface UIImageView (ZinkSkin)
/**
* 将各个皮肤对应的文本颜色传入数组
*/
- (void)zinkSetSkinWithImages:(NSArray<UIImage *> *)array;
@end
UIImageView *imageView;
[imageView zinkSetSkinWithImages:@[[UIImage imageNamed:@"normal1"], [UIImage imageNamed:@"night1"]]];
@interface UIButton (ZinkSkin)
/**
* 将各个皮肤对应的标题颜色传入数组
*/
- (void)zinkSetSkinWithTitleColors:(NSArray<UIColor *> *)array forState:(UIControlState)state;
/**
* 将各个皮肤对应的图标传入数组
*/
- (void)zinkSetSkinWithImage:(NSArray<UIImage *> *)array forState:(UIControlState)state;
/**
* 将各个皮肤对应的背景图传入数组
*/
- (void)zinkSetSkinWithBackgroundImage:(NSArray<UIImage *> *)array forState:(UIControlState)state;
@end
UIButton *button;
[button zinkSetSkinWithBackgroundImage:@[[UIImage imageNamed:@"normal"],
[UIImage imageNamed:@"night"]]
forState:UIControlStateNormal];
[button zinkSetSkinWithBackgroundImage:@[[UIImage imageNamed:@"normal1"],
[UIImage imageNamed:@"night1"]]
forState:UIControlStateHighlighted];
为了防止特殊的视图造成无法换肤,ZinkSkinManager
在每次换肤时会发出通知:kViewSkinChangeNotification
。可以监听该通知来修改相应的视图。
感谢Draveness的无私分享:DKNightVersion