GoKit 是一个 UIKit 扩展库,它增加了一些常用的 UIKit 辅助功能
将依赖项添加到您的 Podfile
pod 'GoKit'
接下来,将头文件导入到您需要使用它的任何位置。
#import <GoKit/GoKit.h>
带十六进制数字的颜色
[UIColor go_colorWithHex:0x8031CCA]; // ARGB
[UIColor go_colorWithHex:0x31CCAA]; // RGB
UIView,带有模糊:为了适应 iOS 7 中的模糊效果,使用了半透明替换
有朋友问,为什么这样做? 我看到了许多 git 小伙伴写了一些替代方案,对 UIimage 进行处理,这是非常耗费性能的做法。为了适应 iOS7 而得不偿失。 UIVisualEffectView 是在 UIView 上覆盖了一层,对下面的 UIImageView 不进行操作。因此,它可以适用于快速切换效果
- (UIView *)go_addBlurWithEffectWithStyle:(UIBlurEffectStyle)style
frame:(CGRect)frame {
if (go_iOS(8)) {
UIVisualEffectView *view = [self effectviewWithframe:frame];
[self addSubview:view];
return view;
} else {
UIView *view = [self effectviewForiOS7Withframe:frame];
[self addSubview:view];
return view;
} }