├── Default-568h@2x.png ├── GYBaseViewCategory ├── Assets.xcassets │ ├── Contents.json │ ├── aaa.imageset │ │ ├── 消息-(4)@2x.png │ │ ├── 消息-(4)@3x.png │ │ └── Contents.json │ └── AppIcon.appiconset │ │ └── Contents.json ├── ViewController.h ├── AViewController.h ├── Speak.h ├── AppDelegate.h ├── main.m ├── Speak.m ├── View │ ├── GYBaseViewHeader.h │ ├── UIImageView+GYConfig.h │ ├── UIImageView+GYConfig.m │ ├── UITextView+GYConfig.h │ ├── UITextField+GYConfig.h │ ├── UILabel+GYConfig.h │ ├── UIView+GYConfig.h │ ├── UILabel+GYConfig.m │ ├── UIButton+GYConfig.h │ ├── UITextField+GYConfig.m │ ├── UITextView+GYConfig.m │ ├── UIButton+GYConfig.m │ └── UIView+GYConfig.m ├── Info.plist ├── Base.lproj │ ├── Main.storyboard │ └── LaunchScreen.storyboard ├── AViewController.m ├── AppDelegate.m └── ViewController.m ├── GYBaseViewCategory.xcodeproj ├── project.xcworkspace │ ├── xcuserdata │ │ └── zhiyuangao.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── xcuserdata │ └── zhiyuangao.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── xcshareddata │ └── xcschemes │ │ └── GYBaseViewCategory.xcscheme └── project.pbxproj ├── GYBaseViewCategory.podspec ├── LICENSE └── README.md /Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imzhiyuanxiaopo/GYBaseViewCategory/HEAD/Default-568h@2x.png -------------------------------------------------------------------------------- /GYBaseViewCategory/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /GYBaseViewCategory/Assets.xcassets/aaa.imageset/消息-(4)@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imzhiyuanxiaopo/GYBaseViewCategory/HEAD/GYBaseViewCategory/Assets.xcassets/aaa.imageset/消息-(4)@2x.png -------------------------------------------------------------------------------- /GYBaseViewCategory/Assets.xcassets/aaa.imageset/消息-(4)@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imzhiyuanxiaopo/GYBaseViewCategory/HEAD/GYBaseViewCategory/Assets.xcassets/aaa.imageset/消息-(4)@3x.png -------------------------------------------------------------------------------- /GYBaseViewCategory.xcodeproj/project.xcworkspace/xcuserdata/zhiyuangao.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imzhiyuanxiaopo/GYBaseViewCategory/HEAD/GYBaseViewCategory.xcodeproj/project.xcworkspace/xcuserdata/zhiyuangao.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /GYBaseViewCategory.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GYBaseViewCategory/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ViewCatagory 4 | // 5 | // Created by zhiyuan gao on 2019/8/4. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /GYBaseViewCategory.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GYBaseViewCategory/AViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AViewController.h 3 | // GYBaseViewCategory 4 | // 5 | // Created by zhiyuan gao on 2019/8/7. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface AViewController : UIViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /GYBaseViewCategory/Speak.h: -------------------------------------------------------------------------------- 1 | // 2 | // Speak.h 3 | // GYBaseViewCategory 4 | // 5 | // Created by zhiyuan gao on 2019/8/19. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface Speak : NSObject 14 | 15 | - (void)speak; 16 | 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /GYBaseViewCategory/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ViewCatagory 4 | // 5 | // Created by zhiyuan gao on 2019/8/4. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /GYBaseViewCategory/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ViewCatagory 4 | // 5 | // Created by zhiyuan gao on 2019/8/4. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /GYBaseViewCategory/Speak.m: -------------------------------------------------------------------------------- 1 | // 2 | // Speak.m 3 | // GYBaseViewCategory 4 | // 5 | // Created by zhiyuan gao on 2019/8/19. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import "Speak.h" 10 | 11 | @interface Speak () 12 | 13 | @property (copy, nonatomic) NSString *name; 14 | 15 | @end 16 | 17 | @implementation Speak 18 | 19 | - (void)speak{ 20 | NSLog(@"My name is :%@" ,self.name); 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /GYBaseViewCategory/Assets.xcassets/aaa.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "消息-(4)@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "消息-(4)@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /GYBaseViewCategory/View/GYBaseViewHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewCatagoryHeader.h 3 | // DJPlatform 4 | // 5 | // Created by zhiyuan gao on 2019/8/2. 6 | // Copyright © 2019 点金台. All rights reserved. 7 | // 8 | 9 | #ifndef ViewCatagoryHeader_h 10 | #define ViewCatagoryHeader_h 11 | 12 | #import "UIButton+GYConfig.h" 13 | #import "UILabel+GYConfig.h" 14 | #import "UIView+GYConfig.h" 15 | #import "UITextField+GYConfig.h" 16 | #import "UITextView+GYConfig.h" 17 | #import "UIImageView+GYConfig.h" 18 | 19 | #endif /* ViewCatagoryHeader_h */ 20 | -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UIImageView+GYConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+GYConfig.h 3 | // GYBaseViewCategory 4 | // 5 | // Created by zhiyuan gao on 2019/8/6. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface UIImageView (GYConfig) 14 | 15 | /** 设置图片(图片名称)*/ 16 | - (UIImageView *(^)(NSString * _Nonnull imageNamed))gyImage; 17 | 18 | ///** 设置图片背景色(也可用uiview父类的方法)*/ 19 | /** 设置背景色*/ 20 | - (UIImageView * _Nonnull (^)(UIColor * _Nonnull))gyImageViewBackgroundColor; 21 | /** 16进制背景色*/ 22 | - (UIImageView * _Nonnull (^)(NSInteger))gyImageViewBackgroundHexColor; 23 | 24 | @end 25 | 26 | NS_ASSUME_NONNULL_END 27 | -------------------------------------------------------------------------------- /GYBaseViewCategory.xcodeproj/xcuserdata/zhiyuangao.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /GYBaseViewCategory.xcodeproj/xcuserdata/zhiyuangao.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | GYBaseViewCategory.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | GYViewCategory.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | ViewCatagory.xcscheme_^#shared#^_ 18 | 19 | orderHint 20 | 0 21 | 22 | 23 | SuppressBuildableAutocreation 24 | 25 | 26C55CC622F6C05100D36C94 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /GYBaseViewCategory.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | 3 | spec.name = "GYBaseViewCategory" 4 | spec.version = "0.1.0" 5 | spec.summary = "视图分类" 6 | spec.description = "常见视图的一些设置,如果一行行去进行设置属性会显得代码麻烦。之前有见到过通过方法设置,但是有的时候又不需要设置那么多属性,方法的参数还需要传nil。因此,采用了链式编程进行属性设置。部分方法在view的分类里,一般是一些通用的属性。部分控件的属性可能没有添加完全,后续会更新。" 7 | 8 | spec.homepage = "https://github.com/imzhiyuanxiaopo/GYBaseViewCategory" 9 | 10 | spec.license = "MIT" 11 | #spec.license = { :type => "MIT", :file => "FILE_LICENSE" } 12 | 13 | spec.author = { "gzy1992123" => "872598520@qq.com" } 14 | spec.authors = { "gzy1992123" => "872598520@qq.com" } 15 | spec.platform = :ios, "9.0" 16 | 17 | spec.source = { :git => "https://github.com/imzhiyuanxiaopo/GYBaseViewCategory.git", :tag => "#{spec.version}" } 18 | 19 | spec.source_files = "GYBaseViewCategory/View/*.{h,m}" 20 | #spec.exclude_files = "Classes/Exclude" 21 | 22 | end 23 | -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UIImageView+GYConfig.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+GYConfig.m 3 | // GYBaseViewCategory 4 | // 5 | // Created by zhiyuan gao on 2019/8/6. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import "UIImageView+GYConfig.h" 10 | 11 | #import "UIView+GYConfig.h" 12 | 13 | @implementation UIImageView (GYConfig) 14 | 15 | - (UIImageView * _Nonnull (^)(NSString * _Nonnull))gyImage{ 16 | return ^(NSString *imageName){ 17 | self.image = [UIImage imageNamed:imageName]; 18 | return self; 19 | }; 20 | } 21 | 22 | // 背景色 23 | - (UIImageView * _Nonnull (^)(UIColor * _Nonnull))gyImageViewBackgroundColor{ 24 | return ^(UIColor *color){ 25 | self.backgroundColor = color; 26 | return self; 27 | }; 28 | } 29 | - (UIImageView * _Nonnull (^)(NSInteger))gyImageViewBackgroundHexColor{ 30 | return ^(NSInteger color){ 31 | self.backgroundColor = [self colorWithHex:color]; 32 | return self; 33 | }; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 高志远 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UITextView+GYConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // UITextView+GYConfig.h 3 | // ViewCatagory 4 | // 5 | // Created by zhiyuan gao on 2019/8/4. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface UITextView (GYConfig) 14 | 15 | /** 设置textview文字*/ 16 | - (UITextView * (^)(NSString * _Nonnull))gyText; 17 | 18 | /** 设置textview字体*/ 19 | - (UITextView * (^)(UIFont * _Nonnull))gyTextViewFont; 20 | /** 设置字体颜色*/ 21 | - (UITextView * (^)(UIColor * _Nonnull))gyTextColor; 22 | /** 16进制字体色*/ 23 | - (UITextView * (^)(NSInteger))gyTextHexColor; 24 | 25 | /** 设置textview的占位符文本*/ 26 | - (UITextView * (^)(NSString * _Nonnull))gyPlaceHolder; 27 | /** 设置占位符字体 28 | 改字体默认跟随文本字体 29 | */ 30 | - (UITextView * (^)(UIFont * _Nonnull))gyPlaceHolderFont; 31 | /** 设置占位符文字颜色*/ 32 | - (UITextView * (^)(UIColor * _Nonnull))gyPlaceHolderColor; 33 | /** 设置占位符16进制颜色*/ 34 | - (UITextView * (^)(NSInteger))gyPlaceHolderHexColor; 35 | /** 设置键盘*/ 36 | - (UITextView * (^)(UIKeyboardType))gyKeyboardType; 37 | 38 | /** 设置文字位置*/ 39 | - (UITextView * (^)(NSTextAlignment))gyAlignment; 40 | 41 | /** 设置背景色*/ 42 | - (UITextView * _Nonnull (^)(UIColor * _Nonnull))gyTextViewBackgroundColor; 43 | /** 16进制背景色*/ 44 | - (UITextView * _Nonnull (^)(NSInteger))gyTextViewBackgroundHexColor; 45 | 46 | @end 47 | 48 | NS_ASSUME_NONNULL_END 49 | -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UITextField+GYConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // UITextField+GYConfig.h 3 | // ViewCatagory 4 | // 5 | // Created by zhiyuan gao on 2019/8/4. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface UITextField (GYConfig) 14 | 15 | /** 设置textfield文字*/ 16 | - (UITextField * (^)(NSString * _Nonnull))gyText; 17 | 18 | #pragma mark - 占位符设置 19 | /** 占位符文字*/ 20 | - (UITextField * (^)(NSString * _Nonnull))gyPlaceHolder; 21 | /** 占位符文字颜色*/ 22 | - (UITextField * (^)(UIColor * _Nonnull))gyPlaceHolderColor; 23 | /** 占位符16进制文字颜色*/ 24 | - (UITextField * (^)(NSInteger))gyPlaceHolderHexColor; 25 | /** 文字颜色*/ 26 | - (UITextField * (^)(UIColor * _Nonnull))gyTextColor; 27 | /** 16进制文字颜色*/ 28 | - (UITextField * (^)(NSInteger))gyTextHexColor; 29 | /** 字体*/ 30 | - (UITextField * (^)(UIFont * _Nonnull))gyFont; 31 | /** 文字位置*/ 32 | - (UITextField * (^)(NSTextAlignment))gyTextAligment; 33 | #pragma mark - 设置左右侧视图时 如果是imageView会显示适合的大小V 自定义视图的话需要设置frame 34 | /** 左侧视图*/ 35 | - (UITextField * (^)(UIView * _Nonnull))gyLeftView; 36 | /** 右侧视图*/ 37 | - (UITextField * (^)(UIView * _Nonnull))gyRightView; 38 | /** j键盘设置*/ 39 | - (UITextField * (^)(UIKeyboardType))gyKeyboardType; 40 | 41 | 42 | /** 设置背景色*/ 43 | - (UITextField * _Nonnull (^)(UIColor * _Nonnull))gyTextFieldBackgroundColor; 44 | /** 16进制背景色*/ 45 | - (UITextField * _Nonnull (^)(NSInteger))gyTextFieldBackgroundHexColor; 46 | 47 | @end 48 | 49 | NS_ASSUME_NONNULL_END 50 | -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UILabel+GYConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // UILabel+DJConfigLabel.h 3 | // DJPlatform 4 | // 5 | // Created by zhiyuan gao on 2019/8/2. 6 | // Copyright © 2019 点金台. All rights reserved. 7 | // 8 | 9 | /* 10 | 采用链式编程的一个label的分类 使用方法:label.gyText(@"asdf").gyTextColor(UIColor.whiteColor).... 11 | 已经将这个类导入到pch文件方便全局调用 12 | (ps:后续如果有可能需要的属性可自行添加) 13 | */ 14 | 15 | #import 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | @interface UILabel (GYConfig) 20 | 21 | /** 设置文字*/ 22 | - (UILabel * _Nonnull (^)(NSString * _Nonnull))gyText; 23 | /** 设置文字颜色color*/ 24 | - (UILabel * _Nonnull (^)(UIColor * _Nonnull))gyTextColor; 25 | /** 设置文字颜色十六进制数字(为了减少依赖 在.m文件里定义一个转换16进制颜色方法)*/ 26 | - (UILabel * _Nonnull (^)(NSInteger))gyTextHexColor; 27 | /** 设置字体*/ 28 | - (UILabel * _Nonnull (^)(UIFont * _Nonnull))gyFont; 29 | /** 设置系统字体 只传入文字大小*/ 30 | - (UILabel * _Nonnull (^)(NSInteger))gySystemFontSize; 31 | /** 设置文字位置*/ 32 | - (UILabel * _Nonnull (^)(NSTextAlignment))gyAlignment; 33 | /** 设置文字富文本*/ 34 | - (UILabel * _Nonnull (^)(NSAttributedString * _Nonnull))gyAttributer; 35 | /** 文字行数*/ 36 | - (UILabel * _Nonnull (^)(NSInteger))gyNumberOfLine; 37 | 38 | /** 39 | 设置背景色 40 | 在初始化时候可以使用 41 | ex: UILabel.new.gyLabelBackgroundColor(UIColor.redColor) 42 | 这种情况返回的是UILabel 不会报类型警告 43 | */ 44 | /** label背景颜色*/ 45 | - (UILabel * _Nonnull (^)(UIColor * _Nonnull))gyLabelBackgroundColor; 46 | /** label16进制背景色*/ 47 | - (UILabel * _Nonnull (^)(NSInteger))gyLabelBackgroundHexColor; 48 | 49 | @end 50 | 51 | NS_ASSUME_NONNULL_END 52 | -------------------------------------------------------------------------------- /GYBaseViewCategory/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 0.1.0 19 | CFBundleVersion 20 | 5 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /GYBaseViewCategory/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /GYBaseViewCategory/AViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AViewController.m 3 | // GYBaseViewCategory 4 | // 5 | // Created by zhiyuan gao on 2019/8/7. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import "AViewController.h" 10 | 11 | #import "ViewController.h" 12 | 13 | #import "GYBaseViewHeader.h" 14 | 15 | @interface AViewController () 16 | 17 | @end 18 | 19 | @implementation AViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view. 24 | [self.navigationController pushViewController:ViewController.new animated:YES]; 25 | 26 | __weak typeof(self) weakself = self; 27 | UILabel *label = (UILabel *)UILabel.new 28 | .gyText(@"长按") 29 | .gyBackgroundColor(UIColor.purpleColor) 30 | .gyGestureTap(^(UITapGestureRecognizer *gesture){ 31 | NSLog(@"短按"); 32 | }) 33 | .gyGestureLongPress(^(UILongPressGestureRecognizer *gesture){ 34 | __strong typeof(weakself) strongSelf = weakself; 35 | NSLog(@"长按"); 36 | [strongSelf dismissViewControllerAnimated:YES completion:nil]; 37 | }) 38 | .gyBorderColor(UIColor.whiteColor) 39 | .gyBorderWidth(1) 40 | .gyGestureLongPressDuratime(1.5) 41 | .gyCustomCornerRadius(UIRectCornerTopRight | UIRectCornerBottomLeft) 42 | .gyCornerRadius(10) 43 | ; 44 | NSNotificationCenter *notification = [NSNotificationCenter defaultCenter]; 45 | [notification addObserver:self selector:@selector(noti) name:@"asdf" object:nil]; 46 | 47 | label.frame = CGRectMake(0, 400, 300, 40); 48 | self.view.gyBackgroundHexColor(0x348122); 49 | [self.view addSubview:label]; 50 | } 51 | 52 | - (void)dealloc{ 53 | NSLog(@"释放了AVIEWCONTROLLER"); 54 | } 55 | 56 | - (void)noti{ 57 | 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /GYBaseViewCategory/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UIView+GYConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+GYConfigView.h 3 | // DJPlatform 4 | // 5 | // Created by zhiyuan gao on 2019/8/2. 6 | // Copyright © 2019 点金台. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface UIView (GYConfig) 14 | 15 | @property (assign, nonatomic) CGFloat gyX; 16 | @property (assign, nonatomic) CGFloat gyY; 17 | @property (assign, nonatomic) CGFloat gyWidth; 18 | @property (assign, nonatomic) CGFloat gyHeight; 19 | @property (assign, nonatomic) CGFloat gyCenterX; 20 | @property (assign, nonatomic) CGFloat gyCenterY; 21 | 22 | #pragma mark - 设置边线 23 | /** 24 | 边线宽度 25 | */ 26 | - (UIView * _Nonnull (^)(CGFloat))gyBorderWidth; 27 | /** 28 | 设置边线颜色 29 | */ 30 | - (UIView * _Nonnull (^)(UIColor * _Nonnull))gyBorderColor; 31 | /** 边线16进制颜色*/ 32 | - (UIView * _Nonnull (^)(NSInteger))gyBorderHexColor; 33 | 34 | /** 35 | 设置圆角 36 | 暂时使用mask来设置 textview使用画图绘制圆角会有问题 37 | */ 38 | - (UIView * _Nonnull (^)(CGFloat))gyCornerRadius; 39 | 40 | /** 41 | 设置想要位置的圆角 42 | GYConer看上面 43 | 参数是BOOL值 填写0 1就行 44 | 暂时未添加设置 没想到好的对所有视图控件的解决办法 45 | */ 46 | //- (UIView * _Nonnull (^)(GYCorner ,CGFloat radius))gyCorner; 47 | 48 | #pragma mark - 设置背景色 子类也可以使用 49 | /** 设置背景色*/ 50 | - (UIView * _Nonnull (^)(UIColor * _Nonnull))gyBackgroundColor; 51 | /** 设置16进制背景色*/ 52 | - (UIView * _Nonnull (^)(NSInteger))gyBackgroundHexColor; 53 | 54 | /** 55 | 16进制颜色转换为color 56 | 其他分类使用这个设置 57 | 58 | @param hexValue hexValue description 59 | @return return value description 60 | */ 61 | - (UIColor *)colorWithHex:(NSInteger)hexValue; 62 | 63 | /** touchinside点击方法*/ 64 | - (UIView * _Nonnull (^)(void(^)(id sender)))gyGestureTap; 65 | 66 | /** touchinside长按方法*/ 67 | - (UIView * _Nonnull (^)(void(^)(id sender)))gyGestureLongPress; 68 | /** 长按持续时间*/ 69 | - (UIView * _Nonnull (^)(NSInteger duration))gyGestureLongPressDuratime; 70 | /** 自定义圆角*/ 71 | - (UIView * _Nonnull (^)(UIRectCorner))gyCustomCornerRadius; 72 | 73 | @end 74 | 75 | NS_ASSUME_NONNULL_END 76 | -------------------------------------------------------------------------------- /GYBaseViewCategory/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UILabel+GYConfig.m: -------------------------------------------------------------------------------- 1 | // 2 | // UILabel+DJConfigLabel.m 3 | // DJPlatform 4 | // 5 | // Created by zhiyuan gao on 2019/8/2. 6 | // Copyright © 2019 点金台. All rights reserved. 7 | // 8 | 9 | #import "UILabel+GYConfig.h" 10 | #import "UIView+GYConfig.h" 11 | 12 | @implementation UILabel (GYConfig) 13 | 14 | - (UILabel * _Nonnull (^)(NSString * _Nonnull))gyText{ 15 | return ^(NSString *text){ 16 | self.text = text; 17 | return self; 18 | }; 19 | } 20 | - (UILabel * _Nonnull (^)(NSAttributedString * _Nonnull))gyAttributer{ 21 | return ^(NSAttributedString *attributed){ 22 | self.attributedText = attributed; 23 | return self; 24 | }; 25 | } 26 | 27 | - (UILabel * _Nonnull (^)(UIColor * _Nonnull))gyLabelBackgroundColor{ 28 | return ^(UIColor *color){ 29 | self.backgroundColor = color; 30 | return self; 31 | }; 32 | } 33 | - (UILabel * _Nonnull (^)(NSInteger))gyLabelBackgroundHexColor{ 34 | return ^(NSInteger color){ 35 | self.backgroundColor = [self colorWithHex:color]; 36 | return self; 37 | }; 38 | } 39 | 40 | - (UILabel * _Nonnull (^)(UIColor * _Nonnull))gyTextColor{ 41 | return ^(UIColor *color){ 42 | self.textColor = color; 43 | return self; 44 | }; 45 | } 46 | 47 | - (UILabel * _Nonnull (^)(NSInteger))gyTextHexColor{ 48 | return ^(NSInteger colorHex){ 49 | self.textColor = [self colorWithHex:colorHex]; 50 | return self; 51 | }; 52 | } 53 | 54 | - (UILabel * _Nonnull (^)(NSInteger))gyNumberOfLine{ 55 | return ^(NSInteger number){ 56 | self.numberOfLines = number; 57 | return self; 58 | }; 59 | } 60 | 61 | - (UILabel * _Nonnull (^)(UIFont * _Nonnull))gyFont{ 62 | return ^(UIFont *font){ 63 | self.font = font; 64 | return self; 65 | }; 66 | } 67 | 68 | - (UILabel * _Nonnull (^)(NSInteger))gySystemFontSize{ 69 | return ^(NSInteger fontSize){ 70 | self.font = [UIFont systemFontOfSize:fontSize]; 71 | return self; 72 | }; 73 | } 74 | 75 | - (UILabel * _Nonnull (^)(NSTextAlignment))gyAlignment{ 76 | return ^(NSTextAlignment alignment){ 77 | self.textAlignment = alignment; 78 | return self; 79 | }; 80 | } 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /GYBaseViewCategory/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ViewCatagory 4 | // 5 | // Created by zhiyuan gao on 2019/8/4. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | //#if DEBUG 21 | // // iOS 22 | // [[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle"] load]; 23 | //#endif 24 | return YES; 25 | } 26 | 27 | 28 | - (void)applicationWillResignActive:(UIApplication *)application { 29 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 30 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 31 | } 32 | 33 | 34 | - (void)applicationDidEnterBackground:(UIApplication *)application { 35 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 36 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 37 | } 38 | 39 | 40 | - (void)applicationWillEnterForeground:(UIApplication *)application { 41 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 42 | } 43 | 44 | 45 | - (void)applicationDidBecomeActive:(UIApplication *)application { 46 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 47 | } 48 | 49 | 50 | - (void)applicationWillTerminate:(UIApplication *)application { 51 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 52 | } 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UIButton+GYConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+DJConfigButton.h 3 | // DJPlatform 4 | // 5 | // Created by zhiyuan gao on 2019/8/2. 6 | // Copyright © 2019 点金台. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface UIButton (GYConfig) 14 | 15 | #pragma mark - 设置各状态文字 16 | /** 普通状态文字*/ 17 | - (UIButton * _Nonnull (^)(NSString * _Nonnull))gyNormalText; 18 | /** 高亮状态文字*/ 19 | - (UIButton * _Nonnull (^)(NSString * _Nonnull))gyHighlightedText; 20 | /** 选中状态文字*/ 21 | - (UIButton * _Nonnull (^)(NSString * _Nonnull))gySelectedText; 22 | 23 | #pragma mark - 设置各状态文字颜色 24 | /** 普通状态文字颜色*/ 25 | - (UIButton * _Nonnull (^)(UIColor * _Nonnull))gyNormalTextColor; 26 | /** 高亮状态文字颜色*/ 27 | - (UIButton * _Nonnull (^)(UIColor * _Nonnull))gyHighlightedTextColor; 28 | /** 选中状态文字颜色*/ 29 | - (UIButton * _Nonnull (^)(UIColor * _Nonnull))gySelectedTextColor; 30 | 31 | /** 设置普通状态16进制文字颜色*/ 32 | - (UIButton * _Nonnull (^)(NSInteger))gyNormalTextHexColor; 33 | /** 设置高亮状态16进制文字颜色*/ 34 | - (UIButton * _Nonnull (^)(NSInteger))gyHighlightedTextHexColor; 35 | /** 设置选中状态16进制文字颜色*/ 36 | - (UIButton * _Nonnull (^)(NSInteger))gySelectedTextHexColor; 37 | 38 | /** 设置背景色*/ 39 | - (UIButton * _Nonnull (^)(UIColor * _Nonnull))gyButtonBackgroundColor; 40 | /** 设置16进制背景色*/ 41 | - (UIButton * _Nonnull (^)(NSInteger))gyButtonBackgroundHexColor; 42 | 43 | /** 设置字体*/ 44 | - (UIButton * _Nonnull (^)(UIFont * _Nonnull))gyFont; 45 | /** 设置系统字体 只传入文字大小*/ 46 | - (UIButton * _Nonnull (^)(NSInteger))gySystemFontSize; 47 | 48 | /** 按钮普通状态图片*/ 49 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gyNormalImage; 50 | /** 按钮选中状态图片*/ 51 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gySelectedImage; 52 | /** 按钮高亮状态图片*/ 53 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gyHighlightedImage; 54 | /** 按钮普通状态背景图*/ 55 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gyNormalBackImage; 56 | /** 按钮高亮状态背景图*/ 57 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gyHighlightedBackImage; 58 | /** 按钮选中状态背景图*/ 59 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gySelectedBackImage; 60 | 61 | /** 设置按钮的状态(常用为selected highlight normal)*/ 62 | - (UIButton * _Nonnull (^)(UIControlState))gyButtonState; 63 | 64 | /** touchinside点击方法*/ 65 | - (UIButton * _Nonnull (^)(void(^)(UIButton *sender)))gyTouchInside; 66 | /** touchoutside点击方法*/ 67 | - (UIButton * _Nonnull (^)(void(^)(UIButton *sender)))gyTouchOutside; 68 | /// 按钮点击限制 默认动画为缩放模式 69 | - (UIButton * _Nonnull (^)(BOOL(^)(void)))gyButtonLimit; 70 | 71 | @end 72 | 73 | NS_ASSUME_NONNULL_END 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GYBaseViewCatogary 2 | 很多时候在初始化控件要对其有一些设置。之前是使用了方法进行设置,例如添加一个工具类,设置一个类方法对label进行设置。参数里大多包涵text,textColor,align,font等等的设置。但是有的时候可能我们只想设置一个文字,并不关心其他属性,而且不想让代码过于冗余。因此使用链式编程来进行设置。 3 | 4 | 这个库顺便为UITextView添加了placeHolder,使用kvc对textView的私有属性进行的赋值。 5 | UIimageview暂时没想到添加什么。 6 | 7 | 圆角属性可以设置圆角的位置 使用的是系统的枚举 8 | 如果一屏展示超过30个圆角,请谨慎使用UIView分类下的设置圆角。暂时没有使用高效化的圆角,会造成离屏渲染。 9 | 10 | 导入: 11 | 在podfile内添加 pod 'GYBaseViewCategory' 12 | 13 | 或者下载源码,将"View"文件夹拖入您的项目 ,并在需要使用的地方 #import "GYBaseViewHeader.h" 14 | 15 | 使用方法: 16 | ``` 17 | UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 300, 40)]; 18 | textView 19 | .gyPlaceHolder(@"adsfasdfasdf") // 设置占位符 20 | .gyPlaceHolderColor(UIColor.darkGrayColor) // 设置占位符颜色 21 | .gyBorderWidth(5) // 设置边线 22 | .gyBorderColor(UIColor.redColor); // 边线颜色 有设置16进制颜色方法 23 | [self.view addSubview:textView]; 24 | ``` 25 | ``` 26 | __weak typeof(self) weakSelf = self; 27 | UIButton *button = (UIButton *)UIButton.new 28 | .gyNormalText(@"我是按钮") // 设置normal状态文字 29 | .gySelectedText(@"我不是按钮了") // 设置选中状态的文字 30 | .gyHighlightedText(@"我又特么是按钮了") // 高亮状态文字 31 | .gyNormalTextHexColor(0x518369) // 设置文字16进制颜色(通过color设置颜色另有方法) 32 | .gySelectedTextHexColor(0x53ab11) // 设置按钮选中文字颜色 33 | .gyHighlightedTextColor(UIColor.purpleColor) // 设置高亮文字颜色 34 | .gyTouchInside(^(UIButton *button){ // 添加UIControlEventTouchUpInside的点击方法 注意循环引用问题 35 | __strong typeof(weakSelf) storngSelf = weakSelf; // 注意循环引用问题 36 | NSLog(@"点击了按钮"); 37 | AViewController *viewController = AViewController.new; 38 | viewController.view.gyBackgroundColor(UIColor.whiteColor); 39 | // [storngSelf presentViewController:viewController animated:YES completion:nil]; 40 | button.gyButtonState(UIControlStateSelected); 41 | }) 42 | .gyTouchOutside(^(UIButton *button){ // 添加UIControlEventTouchUpOutside的点击方法 注意循环引用问题 43 | __strong typeof(weakSelf) storngSelf = weakSelf; // 注意循环引用问题 44 | NSLog(@"点击了按钮 如果点击超出边界"); 45 | AViewController *viewController = AViewController.new; 46 | viewController.view.gyBackgroundColor(UIColor.whiteColor); 47 | [storngSelf presentViewController:viewController animated:YES completion:nil]; 48 | }) 49 | .gyBackgroundColor(UIColor.yellowColor); // 修改背景色(uiview分类 返回的是uiview 所以初始化时使用了(UIButton *)强行转换 取消警告 button分类后添加了设置背景色的方法) 50 | button.frame = CGRectMake(0, 300, 300, 40); 51 | [self.view addSubview:button]; 52 | ``` 53 | ``` 54 | __weak typeof(self) weakself = self; 55 | UILabel *label = (UILabel *)UILabel.new 56 | .gyText(@"asdfasdf") // 设置label文字 57 | .gyTextColor(UIColor.greenColor) // 设置文字颜色 58 | .gyBackgroundColor(UIColor.purpleColor) // 背景色 59 | .gyGestureTap(^(UITapGestureRecognizer *gesture){ // 点击事件 注意循环引用 60 | NSLog(@"短按"); 61 | }) 62 | .gyGestureLongPress(^(UILongPressGestureRecognizer *gesture){ // 长按事件 注意循环引用 63 | __strong typeof(weakself) strongSelf = weakself; 64 | NSLog(@"长按"); 65 | [strongSelf dismissViewControllerAnimated:YES completion:nil]; 66 | }) 67 | .gyGestureLongPressDuratime(1.5); // 设置长按事件事件 如果添加在前面会无效 暂时考虑如果设置时间就有长按方法 68 | label.frame = CGRectMake(0, 400, 300, 40); 69 | [self.view addSubview:label]; 70 | ``` 71 | 暂时支持UILabel UIButton UITextField UITextView几个控件,并对textview添加了placeholder属性,使用方式类似于uitextfiled甚至更加简便。 72 | 全是基于链式编程,如果有不了解的属性去对应控件的声明文件看即可。 73 | -------------------------------------------------------------------------------- /GYBaseViewCategory.xcodeproj/xcshareddata/xcschemes/GYBaseViewCategory.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /GYBaseViewCategory/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ViewCatagory 4 | // 5 | // Created by zhiyuan gao on 2019/8/4. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "GYBaseViewHeader.h" 11 | 12 | #import "Speak.h" 13 | 14 | #import "AViewController.h" 15 | 16 | @interface ViewController () 17 | 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | 25 | 26 | UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 50, 300, 40)]; 27 | textView 28 | .gyText(@"我是默认的文字 并不是placeholder哦 并且我是textView哦 不信我给您换个行您看看? \n看出来我是textview了吧") 29 | .gyPlaceHolder(@"adsfasdfasdf") 30 | .gyPlaceHolderColor(UIColor.darkGrayColor) 31 | .gyBorderWidth(5) 32 | .gyBorderColor(UIColor.redColor); 33 | [self.view addSubview:textView]; 34 | UITextView *textView1 = (UITextView *)UITextView.new 35 | .gyPlaceHolder(@"中文中文中文") 36 | .gyPlaceHolderHexColor(0x43ab92) 37 | .gyAlignment(NSTextAlignmentRight) 38 | .gyBorderWidth(5) 39 | .gyBorderColor(UIColor.orangeColor) 40 | .gyCustomCornerRadius(UIRectCornerTopRight | UIRectCornerTopLeft); 41 | textView1.frame = CGRectMake(0, 100, 300, 40); 42 | [self.view addSubview:textView1]; 43 | 44 | UITextField *textField = UITextField.new 45 | .gyPlaceHolderHexColor(0xabc418) 46 | .gyPlaceHolder(@"测试用的textfield") 47 | .gyLeftView(UIImageView.new 48 | .gyImage(@"aaa")); 49 | textField.frame = CGRectMake(0, 200, 300, 40); 50 | [self.view addSubview:textField]; 51 | 52 | __weak typeof(self) weakSelf = self; 53 | __block int i = 0; 54 | UIButton *button = (UIButton *)UIButton.new 55 | .gyNormalText(@"我是按钮") // 设置normal状态文字 56 | .gySelectedText(@"我不是按钮了") // 设置选中状态的文字 57 | .gyHighlightedText(@"我又特么是按钮了") // 高亮状态文字 58 | .gyNormalTextHexColor(0x518369) // 设置文字16进制颜色(通过color设置颜色另有方法) 59 | .gySelectedTextHexColor(0x53ab11) 60 | .gyHighlightedTextColor(UIColor.purpleColor) 61 | .gyButtonLimit(^(){// 添加按钮点击限制 会屏蔽所有的动画效果 动画暂时做了这一个 62 | BOOL canClick = i <= 3; 63 | return canClick; 64 | }) 65 | .gyTouchInside(^(UIButton *button){ // 添加UIControlEventTouchUpInside的点击方法 66 | NSLog(@"点击了按钮"); 67 | i ++; 68 | __strong typeof(weakSelf) storngSelf = weakSelf; 69 | button.gyButtonState(UIControlStateSelected); 70 | }) 71 | .gyTouchOutside(^(UIButton *button){ // 添加UIControlEventTouchUpOutside的点击方法 72 | __strong typeof(weakSelf) storngSelf = weakSelf; 73 | NSLog(@"点击了按钮 如果点击超出边界"); 74 | AViewController *viewController = AViewController.new; 75 | // viewController.view.gyBackgroundColor(UIColor.whiteColor); 76 | [storngSelf presentViewController:viewController animated:YES completion:nil]; 77 | }) 78 | .gyBackgroundColor(UIColor.yellowColor); // 修改背景色(uiview分类 返回的是uiview 所以初始化时使用了(UIButton *)强行转换 取消警告 button分类后添加了设置背景色的方法) 79 | button.frame = CGRectMake(0, 300, 300, 40); 80 | [self.view addSubview:button]; 81 | 82 | UILabel *label = (UILabel *)UILabel.new 83 | .gyText(@"asdfasdf") 84 | .gyTextColor(UIColor.greenColor) 85 | .gyBackgroundColor(UIColor.purpleColor) 86 | .gyGestureTap(^(UITapGestureRecognizer *gesture){ 87 | NSLog(@"点击了label%@" ,weakSelf); 88 | }); 89 | label.frame = CGRectMake(0, 400, 300, 40); 90 | [self.view addSubview:label]; 91 | } 92 | 93 | - (void)clickView{ 94 | NSLog(@"sdf"); 95 | } 96 | 97 | - (Speak *)speak1{ 98 | return Speak.new; 99 | } 100 | 101 | - (void)dealloc{ 102 | NSLog(@"adfasdfasdfasdfasfa"); 103 | } 104 | 105 | - (void)injected{ 106 | self.view.backgroundColor = [UIColor whiteColor]; 107 | UILabel *label = [UILabel new].gyText(@"asdfkjhasjldfkasdfjasf"); 108 | label.frame = self.view.bounds; 109 | [self.view addSubview:label]; 110 | } 111 | 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UITextField+GYConfig.m: -------------------------------------------------------------------------------- 1 | // 2 | // UITextField+GYConfig.m 3 | // ViewCatagory 4 | // 5 | // Created by zhiyuan gao on 2019/8/4. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import "UITextField+GYConfig.h" 10 | 11 | #import "UIView+GYConfig.h" 12 | 13 | #import 14 | 15 | @interface UITextField () 16 | 17 | /** 占位符文字颜色*/ 18 | @property (strong ,nonatomic) UIColor *placeHolderColor; 19 | /** 占位符文字*/ 20 | @property (copy ,nonatomic) NSString *placeholderText; 21 | 22 | @end 23 | 24 | static char PHColor; 25 | static char PHText; 26 | 27 | @implementation UITextField (GYConfig) 28 | 29 | - (UITextField * _Nonnull (^)(NSString * _Nonnull))gyText{ 30 | return ^(NSString *text){ 31 | self.text = text; 32 | return self; 33 | }; 34 | } 35 | 36 | - (UITextField * _Nonnull (^)(NSString * _Nonnull))gyPlaceHolder{ 37 | return ^(NSString *placeH){ 38 | self.placeholderText = placeH; 39 | if (!self.placeHolderColor) { 40 | self.placeholder = placeH; 41 | return self; 42 | }else{ 43 | [self initPlaceholder]; 44 | return self; 45 | } 46 | }; 47 | } 48 | - (UITextField * _Nonnull (^)(UIColor * _Nonnull))gyPlaceHolderColor{ 49 | return ^(UIColor *color){ 50 | self.placeHolderColor = color; 51 | if (!self.placeholderText) { 52 | self.placeholderText = @""; 53 | } 54 | [self initPlaceholder]; 55 | return self; 56 | }; 57 | } 58 | 59 | - (UITextField * _Nonnull (^)(NSInteger))gyPlaceHolderHexColor{ 60 | return ^(NSInteger hexColor){ 61 | self.placeHolderColor = [self colorWithHex:hexColor]; 62 | if (!self.placeholderText) { 63 | self.placeholderText = @""; 64 | } 65 | [self initPlaceholder]; 66 | return self; 67 | }; 68 | } 69 | 70 | - (UITextField * _Nonnull (^)(UIColor * _Nonnull))gyTextColor{ 71 | return ^(UIColor *color){ 72 | self.textColor = color; 73 | return self; 74 | }; 75 | } 76 | 77 | - (UITextField * _Nonnull (^)(NSInteger))gyTextHexColor{ 78 | return ^(NSInteger hexColor){ 79 | self.textColor = [self colorWithHex:hexColor]; 80 | return self; 81 | }; 82 | } 83 | 84 | - (UITextField * _Nonnull (^)(UIFont * _Nonnull))gyFont{ 85 | return ^(UIFont *font){ 86 | self.font = font; 87 | return self; 88 | }; 89 | } 90 | 91 | - (UITextField * _Nonnull (^)(NSTextAlignment))gyTextAligment{ 92 | return ^(NSTextAlignment align){ 93 | self.textAlignment = align; 94 | return self; 95 | }; 96 | } 97 | 98 | - (UITextField * _Nonnull (^)(UIView * _Nonnull))gyLeftView{ 99 | return ^(UIView *view){ 100 | if ([view isKindOfClass:[UIImageView class]]) { 101 | UIImageView *imageView = (UIImageView *)view; 102 | UIImage *image = imageView.image; 103 | CGRect imageRect = CGRectMake(0, 0, image.size.width ,image.size.height); 104 | view.frame = imageRect; 105 | } 106 | self.leftView = view; 107 | self.leftViewMode = UITextFieldViewModeAlways; 108 | return self; 109 | }; 110 | } 111 | 112 | - (UITextField * _Nonnull (^)(UIView * _Nonnull))gyRightView{ 113 | return ^(UIView *view){ 114 | if ([view isKindOfClass:[UIImageView class]]) { 115 | UIImageView *imageView = (UIImageView *)view; 116 | UIImage *image = imageView.image; 117 | CGRect imageRect = CGRectMake(0, 0, image.size.width ,image.size.height); 118 | view.frame = imageRect; 119 | } 120 | self.rightView = view; 121 | self.rightViewMode = UITextFieldViewModeAlways; 122 | return self; 123 | }; 124 | } 125 | 126 | - (UITextField * _Nonnull (^)(UIKeyboardType))gyKeyboardType{ 127 | return ^(UIKeyboardType type){ 128 | self.keyboardType = type; 129 | return self; 130 | }; 131 | } 132 | 133 | - (void)initPlaceholder{ 134 | NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:self.placeholderText attributes:@{NSForegroundColorAttributeName : self.placeHolderColor ,NSFontAttributeName : self.font}]; 135 | self.attributedPlaceholder = attrString; 136 | } 137 | // 背景色 138 | - (UITextField * _Nonnull (^)(UIColor * _Nonnull))gyTextFieldBackgroundColor{ 139 | return ^(UIColor *color){ 140 | self.backgroundColor = color; 141 | return self; 142 | }; 143 | } 144 | - (UITextField * _Nonnull (^)(NSInteger))gyTextFieldBackgroundHexColor{ 145 | return ^(NSInteger color){ 146 | self.backgroundColor = [self colorWithHex:color]; 147 | return self; 148 | }; 149 | } 150 | 151 | #pragma mark - 下面就是属性的初始化了 152 | - (UIColor *)placeHolderColor{ 153 | return objc_getAssociatedObject(self, &PHColor); 154 | } 155 | 156 | - (void)setPlaceHolderColor:(UIColor *)placeHolderColor{ 157 | objc_setAssociatedObject(self, &PHColor, placeHolderColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 158 | } 159 | 160 | - (NSString *)placeholderText{ 161 | return objc_getAssociatedObject(self, &PHText); 162 | } 163 | 164 | - (void)setPlaceholderText:(NSString *)placeholderText{ 165 | objc_setAssociatedObject(self, &PHText, placeholderText, OBJC_ASSOCIATION_COPY_NONATOMIC); 166 | } 167 | 168 | @end 169 | -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UITextView+GYConfig.m: -------------------------------------------------------------------------------- 1 | // 2 | // UITextView+GYConfig.m 3 | // ViewCatagory 4 | // 5 | // Created by zhiyuan gao on 2019/8/4. 6 | // Copyright © 2019 Zhiyuan Gao. All rights reserved. 7 | // 8 | 9 | #import "UITextView+GYConfig.h" 10 | 11 | #import "UIView+GYConfig.h" 12 | 13 | #import 14 | 15 | static char PHKEY; 16 | static char PHFONTKEY; 17 | 18 | @interface UITextView () 19 | 20 | /** tv显示的占位符*/ 21 | @property (strong, nonatomic) UILabel *placeHolderLabel; 22 | @property (assign, nonatomic) UIFont *placeHolderFont; 23 | /** 是否完成对placeHolder的设置*/ 24 | @property (assign, nonatomic) BOOL placeHolderComplete; // 使label的frame计算只运行一次 减小cpu开销 25 | 26 | @end 27 | 28 | static char COMPLETEKEY; 29 | 30 | @implementation UITextView (GYConfig) 31 | 32 | #pragma mark - 获取真实高度 33 | - (void)layoutSubviews{ 34 | [super layoutSubviews]; 35 | if (self.placeHolderComplete) { 36 | return; 37 | } 38 | CGFloat width = self.frame.size.width - self.textContainerInset.left - self.textContainerInset.right - 10; 39 | self.placeHolderLabel.frame = CGRectMake(self.textContainerInset.left + 5, self.textContainerInset.top, width, 0); 40 | [self.placeHolderLabel sizeToFit]; 41 | if (self.textAlignment == NSTextAlignmentRight) { 42 | self.placeHolderLabel.gyX = self.gyWidth - 5 - self.placeHolderLabel.gyWidth; 43 | } 44 | if (self.textAlignment == NSTextAlignmentCenter) { 45 | self.placeHolderLabel.gyCenterX = self.gyCenterX; 46 | } 47 | if (self.placeHolderLabel.gyWidth > 0 && self.placeHolderLabel.gyHeight > 0) { 48 | self.placeHolderComplete = YES; 49 | } 50 | } 51 | 52 | - (UITextView * _Nonnull (^)(NSString * _Nonnull))gyText{ 53 | return ^(NSString *text){ 54 | [self initLabel]; 55 | self.text = text; 56 | return self; 57 | }; 58 | } 59 | 60 | - (UITextView * _Nonnull (^)(UIFont * _Nonnull))gyTextViewFont{ 61 | return ^(UIFont *font){ 62 | self.font = font; 63 | self.placeHolderLabel.font = font; 64 | return self; 65 | }; 66 | } 67 | - (UITextView * _Nonnull (^)(UIColor * _Nonnull))gyTextColor{ 68 | return ^(UIColor *color){ 69 | self.textColor = color; 70 | return self; 71 | }; 72 | } 73 | - (UITextView * _Nonnull (^)(NSInteger))gyTextHexColor{ 74 | return ^(NSInteger hexColor){ 75 | self.textColor = [self colorWithHex:hexColor]; 76 | return self; 77 | }; 78 | } 79 | 80 | - (UITextView * _Nonnull (^)(NSString * _Nonnull))gyPlaceHolder{ 81 | return ^(NSString *ph){ 82 | [self initLabel]; 83 | self.placeHolderLabel.text = ph; 84 | return self; 85 | }; 86 | } 87 | 88 | - (UITextView * _Nonnull (^)(UIFont * _Nonnull))gyPlaceHolderFont{ 89 | return ^(UIFont *font){ 90 | [self initLabel]; 91 | self.placeHolderLabel.font = font; 92 | self.placeHolderFont = font; 93 | return self; 94 | }; 95 | } 96 | 97 | - (UITextView * _Nonnull (^)(UIColor * _Nonnull))gyPlaceHolderColor{ 98 | return ^(UIColor *color){ 99 | [self initLabel]; 100 | self.placeHolderLabel.textColor = color; 101 | return self; 102 | }; 103 | } 104 | - (UITextView * _Nonnull (^)(NSInteger))gyPlaceHolderHexColor{ 105 | return ^(NSInteger hexColor){ 106 | self.placeHolderLabel.textColor = [self colorWithHex:hexColor]; 107 | return self; 108 | }; 109 | } 110 | 111 | - (UITextView * _Nonnull (^)(UIKeyboardType))gyKeyboardType{ 112 | return ^(UIKeyboardType type){ 113 | self.keyboardType = type; 114 | return self; 115 | }; 116 | } 117 | 118 | - (UITextView * _Nonnull (^)(NSTextAlignment))gyAlignment{ 119 | return ^(NSTextAlignment align){ 120 | self.textAlignment = align; 121 | return self; 122 | }; 123 | } 124 | 125 | // 背景色 126 | - (UITextView * _Nonnull (^)(UIColor * _Nonnull))gyTextViewBackgroundColor{ 127 | return ^(UIColor *color){ 128 | self.backgroundColor = color; 129 | return self; 130 | }; 131 | } 132 | - (UITextView * _Nonnull (^)(NSInteger))gyTextViewBackgroundHexColor{ 133 | return ^(NSInteger color){ 134 | self.backgroundColor = [self colorWithHex:color]; 135 | return self; 136 | }; 137 | } 138 | 139 | #pragma mark - 下面是初始化 140 | - (UILabel *)placeHolderLabel{ 141 | return objc_getAssociatedObject(self, &PHKEY); 142 | } 143 | 144 | - (void)setPlaceHolderLabel:(UILabel *)placeHolderLabel{ 145 | objc_setAssociatedObject(self, &PHKEY, placeHolderLabel, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 146 | } 147 | 148 | - (UIFont *)placeHolderFont{ 149 | return objc_getAssociatedObject(self, &PHFONTKEY); 150 | } 151 | 152 | - (void)setPlaceHolderFont:(UIFont *)placeHolderFont{ 153 | objc_setAssociatedObject(self, &PHFONTKEY, placeHolderFont, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 154 | } 155 | 156 | - (void)initLabel{ 157 | if (!self.placeHolderLabel) { 158 | self.placeHolderLabel = [[UILabel alloc] init]; 159 | self.placeHolderLabel.font = [UIFont systemFontOfSize:12]; 160 | self.placeHolderLabel.numberOfLines = 0; 161 | [self addSubview:self.placeHolderLabel]; 162 | [self setValue:self.placeHolderLabel forKey:@"_placeholderLabel"]; 163 | } 164 | } 165 | 166 | - (BOOL)placeHolderComplete{ 167 | return (BOOL)[objc_getAssociatedObject(self, &COMPLETEKEY) boolValue]; 168 | } 169 | 170 | - (void)setPlaceHolderComplete:(BOOL)placeHolderComplete{ 171 | objc_setAssociatedObject(self, &COMPLETEKEY, @(placeHolderComplete), OBJC_ASSOCIATION_ASSIGN); 172 | } 173 | 174 | @end 175 | -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UIButton+GYConfig.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+DJConfigButton.m 3 | // DJPlatform 4 | // 5 | // Created by zhiyuan gao on 2019/8/2. 6 | // Copyright © 2019 点金台. All rights reserved. 7 | // 8 | 9 | #import "UIButton+GYConfig.h" 10 | 11 | #import 12 | 13 | #import "UIView+GYConfig.h" 14 | 15 | static char observerkey; 16 | 17 | @interface GYButtonTarget : NSObject 18 | 19 | @property (copy ,nonatomic) void(^block)(UIButton *sender); 20 | - (void)clickButton:(UIButton *)button; 21 | 22 | @end 23 | 24 | @interface UIButton () 25 | 26 | /** 可能有多种点击事件 因此用多个targets*/ 27 | @property (strong, nonatomic) NSMutableArray *targets; 28 | /// 是否可以点击按钮 29 | @property (copy, nonatomic) BOOL(^canClickButton)(void); 30 | 31 | @end 32 | 33 | @implementation GYButtonTarget 34 | 35 | - (instancetype)initWithBlock:(void(^)(UIButton *))block{ 36 | if ((self = [super init])) { 37 | _block = [block copy]; 38 | } 39 | return self; 40 | } 41 | 42 | - (void)clickButton:(UIButton *)button{ 43 | if (_block) { 44 | if (button.canClickButton && !button.canClickButton()) { 45 | CAKeyframeAnimation *frameAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; 46 | frameAnimation.values = @[@1.0 ,@1.2 ,@0.8 ,@1.2 ,@0.8 ,@1.2 ,@1.0]; 47 | frameAnimation.duration = 0.55; 48 | frameAnimation.repeatCount = 1; 49 | frameAnimation.autoreverses = NO; 50 | [button.layer addAnimation:frameAnimation forKey:@"scale"]; 51 | return; 52 | } 53 | _block(button); 54 | } 55 | } 56 | 57 | @end 58 | 59 | static char buttonlimit_key; 60 | 61 | @implementation UIButton (GYConfig) 62 | 63 | #pragma mark - 设置各状态文字 64 | - (UIButton * _Nonnull (^)(NSString * _Nonnull))gyNormalText{ 65 | return ^(NSString *text){ 66 | [self setTitle:text forState:UIControlStateNormal]; 67 | return self; 68 | }; 69 | } 70 | - (UIButton * _Nonnull (^)(NSString * _Nonnull))gySelectedText{ 71 | return ^(NSString *text){ 72 | [self setTitle:text forState:UIControlStateSelected]; 73 | return self; 74 | }; 75 | } 76 | - (UIButton * _Nonnull (^)(NSString * _Nonnull))gyHighlightedText{ 77 | return ^(NSString *text){ 78 | [self setTitle:text forState:UIControlStateHighlighted]; 79 | return self; 80 | }; 81 | } 82 | 83 | - (UIButton * _Nonnull (^)(UIColor * _Nonnull))gyButtonBackgroundColor{ 84 | return ^(UIColor *color){ 85 | self.backgroundColor = color; 86 | return self; 87 | }; 88 | } 89 | - (UIButton * _Nonnull (^)(NSInteger))gyButtonBackgroundHexColor{ 90 | return ^(NSInteger color){ 91 | self.backgroundColor = [self colorWithHex:color]; 92 | return self; 93 | }; 94 | } 95 | 96 | #pragma mark - 各状态文字颜色 97 | - (UIButton * _Nonnull (^)(UIColor * _Nonnull))gyNormalTextColor{ 98 | return ^(UIColor *color){ 99 | [self setTitleColor:color forState:UIControlStateNormal]; 100 | return self; 101 | }; 102 | } 103 | - (UIButton * _Nonnull (^)(UIColor * _Nonnull))gySelectedTextColor{ 104 | return ^(UIColor *color){ 105 | [self setTitleColor:color forState:UIControlStateSelected]; 106 | return self; 107 | }; 108 | } 109 | - (UIButton * _Nonnull (^)(UIColor * _Nonnull))gyHighlightedTextColor{ 110 | return ^(UIColor *color){ 111 | [self setTitleColor:color forState:UIControlStateHighlighted]; 112 | return self; 113 | }; 114 | } 115 | 116 | - (UIButton * _Nonnull (^)(NSInteger))gyNormalTextHexColor{ 117 | return ^(NSInteger colorHex){ 118 | [self setTitleColor:[self colorWithHex:colorHex] forState:UIControlStateNormal]; 119 | return self; 120 | }; 121 | } 122 | - (UIButton * _Nonnull (^)(NSInteger))gySelectedTextHexColor{ 123 | return ^(NSInteger colorHex){ 124 | [self setTitleColor:[self colorWithHex:colorHex] forState:UIControlStateSelected]; 125 | return self; 126 | }; 127 | } 128 | - (UIButton * _Nonnull (^)(NSInteger))gyHighlightedTextHexColor{ 129 | return ^(NSInteger colorHex){ 130 | [self setTitleColor:[self colorWithHex:colorHex] forState:UIControlStateHighlighted]; 131 | return self; 132 | }; 133 | } 134 | 135 | - (UIButton * _Nonnull (^)(UIFont * _Nonnull))gyFont{ 136 | return ^(UIFont *font){ 137 | self.titleLabel.font = font; 138 | return self; 139 | }; 140 | } 141 | 142 | - (UIButton * _Nonnull (^)(NSInteger))gySystemFontSize{ 143 | return ^(NSInteger fontSize){ 144 | self.titleLabel.font = [UIFont systemFontOfSize:fontSize]; 145 | return self; 146 | }; 147 | } 148 | 149 | - (UIButton * _Nonnull (^)(UIControlState))gyButtonState{ 150 | return ^(UIControlState state){ 151 | switch (state) { 152 | case UIControlStateSelected: 153 | self.selected = YES; 154 | break; 155 | case UIControlStateNormal: 156 | self.selected = NO; 157 | self.highlighted = NO; 158 | break; 159 | case UIControlStateHighlighted: 160 | self.highlighted = YES; 161 | break; 162 | default: 163 | break; 164 | } 165 | return self; 166 | }; 167 | } 168 | 169 | #pragma mark - 图片的设置 170 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gyNormalImage{ 171 | return ^(UIImage *image){ 172 | [self setImage:image forState:UIControlStateNormal]; 173 | return self; 174 | }; 175 | } 176 | 177 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gyHighlightedImage{ 178 | return ^(UIImage *image){ 179 | [self setImage:image forState:UIControlStateHighlighted]; 180 | return self; 181 | }; 182 | } 183 | 184 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gySelectedImage{ 185 | return ^(UIImage *image){ 186 | [self setImage:image forState:UIControlStateSelected]; 187 | return self; 188 | }; 189 | } 190 | 191 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gyNormalBackImage{ 192 | return ^(UIImage *image){ 193 | [self setBackgroundImage:image forState:UIControlStateNormal]; 194 | return self; 195 | }; 196 | } 197 | 198 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gyHighlightedBackImage{ 199 | return ^(UIImage *image){ 200 | [self setBackgroundImage:image forState:UIControlStateHighlighted]; 201 | return self; 202 | }; 203 | } 204 | 205 | - (UIButton * _Nonnull (^)(UIImage * _Nonnull))gySelectedBackImage{ 206 | return ^(UIImage *image){ 207 | [self setBackgroundImage:image forState:UIControlStateSelected]; 208 | return self; 209 | }; 210 | } 211 | 212 | - (UIButton * _Nonnull (^)(void(^)(UIButton *sender)))gyTouchInside{ 213 | return [self gyTouchWithEvent:UIControlEventTouchUpInside]; 214 | } 215 | 216 | - (UIButton * _Nonnull (^)(void (^ _Nonnull)(UIButton * _Nonnull)))gyTouchOutside{ 217 | return [self gyTouchWithEvent:UIControlEventTouchUpOutside]; 218 | } 219 | 220 | /** 221 | 点击按钮时调用的方法 222 | 223 | @param event event description 224 | */ 225 | - (UIButton * _Nonnull (^)(void(^)(UIButton *sender)))gyTouchWithEvent:(UIControlEvents)event{ 226 | return ^(void(^block)(UIButton *sender)){ 227 | GYButtonTarget *target = [[GYButtonTarget alloc] initWithBlock:block]; 228 | [self addTarget:target action:@selector(clickButton:) forControlEvents:event]; 229 | NSMutableArray *targets = [self targets]; 230 | [targets addObject:target]; 231 | return self; 232 | }; 233 | } 234 | 235 | - (UIButton * _Nonnull (^)(BOOL (^ _Nonnull)(void)))gyButtonLimit{ 236 | return ^(BOOL(^block)(void)){ 237 | self.canClickButton = block; 238 | return self; 239 | }; 240 | } 241 | 242 | #pragma mark - 为按钮添加一个target属性 243 | - (NSMutableArray *)targets{ 244 | NSMutableArray *targets = objc_getAssociatedObject(self, &observerkey); 245 | if (!targets) { 246 | targets = [NSMutableArray array]; 247 | objc_setAssociatedObject(self, &observerkey, targets, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 248 | } 249 | return targets; 250 | } 251 | 252 | - (BOOL (^)(void))canClickButton{ 253 | return objc_getAssociatedObject(self, &buttonlimit_key); 254 | } 255 | 256 | - (void)setCanClickButton:(BOOL (^)(void))canClickButton{ 257 | objc_setAssociatedObject(self, &buttonlimit_key, canClickButton, OBJC_ASSOCIATION_COPY_NONATOMIC); 258 | } 259 | 260 | @end 261 | -------------------------------------------------------------------------------- /GYBaseViewCategory/View/UIView+GYConfig.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+GYConfigView.m 3 | // DJPlatform 4 | // 5 | // Created by zhiyuan gao on 2019/8/2. 6 | // Copyright © 2019 点金台. All rights reserved. 7 | // 8 | 9 | #import "UIView+GYConfig.h" 10 | 11 | #import 12 | 13 | @interface GYGestureTarget : NSObject 14 | 15 | @property (copy ,nonatomic) void(^block)(id sender); 16 | 17 | - (void)gestureTap:(id)sender; 18 | 19 | @end 20 | 21 | @implementation GYGestureTarget 22 | 23 | - (instancetype)initWithBlock:(void(^)(id))block{ 24 | if ((self = [super init])) { 25 | _block = block; 26 | } 27 | return self; 28 | } 29 | 30 | - (void)gestureTap:(id)sender{ 31 | if (_block) { 32 | _block(sender); 33 | } 34 | } 35 | 36 | - (void)dealloc{ 37 | NSLog(@"释放了%s" ,__func__); 38 | } 39 | 40 | @end 41 | 42 | static char const GESTURETARGETKEY; 43 | 44 | @interface UIView () 45 | 46 | /// 圆角属性相关 47 | @property (assign, nonatomic) CGFloat radius; 48 | @property (assign, nonatomic) UIRectCorner corner; 49 | 50 | @property (strong, nonatomic) NSMutableArray *gyTargets; 51 | /// 贝塞尔路径 52 | @property (strong, nonatomic) UIBezierPath *bezierPath; 53 | /// 边框宽度 54 | @property (assign, nonatomic) CGFloat borderWidth; 55 | /// 边框颜色 56 | @property (strong, nonatomic) UIColor *borderColor; 57 | 58 | @end 59 | 60 | // 圆角弧度key 61 | static char RADIUSKEY; 62 | // 圆角切图key 63 | static char CORNERKEY; 64 | // 贝塞尔路径key 65 | static char BEZIERPATHKEY; 66 | // 边框颜色key 67 | static char BORDERCOLORKEY; 68 | // 边框宽度key 69 | static char BORDERWIDTHKEY; 70 | 71 | @implementation UIView (GYConfig) 72 | 73 | - (void)layoutSubviews{ 74 | if (self.corner && self.radius) { 75 | [self cornerImage:self.radius]; 76 | }else{ 77 | if (!self.corner && self.radius) { 78 | self.corner = 15; 79 | [self cornerImage:self.radius]; 80 | } 81 | if (self.corner && !self.radius) { 82 | self.radius = MIN(self.gyWidth / 2,self.gyHeight / 2); 83 | [self cornerImage:self.radius]; 84 | } 85 | if (!self.corner && !self.radius) { 86 | if (self.borderWidth) { 87 | self.layer.borderWidth = self.borderWidth; 88 | } 89 | if (self.borderColor) { 90 | self.layer.borderColor = self.borderColor.CGColor; 91 | } 92 | } 93 | } 94 | } 95 | 96 | - (UIView * _Nonnull (^)(CGFloat))gyBorderWidth{ 97 | return ^(CGFloat bw){ 98 | self.borderWidth = bw; 99 | return self; 100 | }; 101 | } 102 | - (UIView * _Nonnull (^)(UIColor * _Nonnull))gyBorderColor{ 103 | return ^(UIColor *color){ 104 | self.borderColor = color; 105 | return self; 106 | }; 107 | } 108 | - (UIView * _Nonnull (^)(NSInteger))gyBorderHexColor{ 109 | return ^(NSInteger hex){ 110 | self.borderColor = [self colorWithHex:hex]; 111 | return self; 112 | }; 113 | } 114 | 115 | - (UIView * _Nonnull (^)(UIColor * _Nonnull))gyBackgroundColor{ 116 | return ^(UIColor *color){ 117 | self.backgroundColor = color; 118 | return self; 119 | }; 120 | } 121 | - (UIView * _Nonnull (^)(NSInteger))gyBackgroundHexColor{ 122 | return ^(NSInteger color){ 123 | self.backgroundColor = [self colorWithHex:color]; 124 | return self; 125 | }; 126 | } 127 | 128 | - (UIView * _Nonnull (^)(CGFloat))gyCornerRadius{ 129 | return ^(CGFloat radius){ 130 | self.radius = radius; 131 | // [self cornerImageView]; 132 | return self; 133 | }; 134 | } 135 | 136 | /** 137 | 自己切圆角图片 138 | 139 | @param radius radius description 140 | */ 141 | - (void)cornerImage:(CGFloat)radius{ 142 | self.bezierPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:self.corner cornerRadii:CGSizeMake(self.radius, self.radius)]; 143 | NSLog(@"%ld" ,self.corner); 144 | CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init]; 145 | //设置大小 146 | maskLayer.frame = self.bounds; 147 | //设置图形样子 148 | maskLayer.path = self.bezierPath.CGPath; 149 | self.layer.mask = maskLayer; 150 | 151 | CAShapeLayer *borderLayer=[CAShapeLayer layer]; 152 | borderLayer.path= self.bezierPath.CGPath; 153 | borderLayer.fillColor = [UIColor clearColor].CGColor; 154 | borderLayer.strokeColor= self.borderColor.CGColor; 155 | borderLayer.lineWidth= self.borderWidth * 2; 156 | borderLayer.frame=self.bounds; 157 | [self.layer addSublayer:borderLayer]; 158 | } 159 | 160 | - (UIView * _Nonnull (^)(UIRectCorner))gyCustomCornerRadius{ 161 | return ^(UIRectCorner corner){ 162 | self.corner = corner; 163 | NSLog(@"%ld" ,corner); 164 | // [self cornerImageView]; 165 | return self; 166 | }; 167 | } 168 | 169 | /** 170 | 16进制颜色转换为color 171 | 172 | @param hexValue hexValue description 173 | @return return value description 174 | */ 175 | - (UIColor *)colorWithHex:(NSInteger)hexValue{ 176 | return [UIColor colorWithRed:((float)((hexValue & 0xFF0000) >> 16)) / 255.0 green:((float)((hexValue & 0xFF00) >> 8)) / 255.0 blue:((float)(hexValue & 0xFF)) / 255.0 alpha:1.0f]; 177 | } 178 | 179 | /** 180 | 16进制字符串转16进制数字 181 | 182 | @param hexString hexString description 183 | @return return value description 184 | */ 185 | - (NSInteger)numberWithHexString:(NSString *)hexString{ 186 | const char *hexChar = [hexString cStringUsingEncoding:NSUTF8StringEncoding]; 187 | int hexNumber; 188 | sscanf(hexChar, "%x", &hexNumber); 189 | return (NSInteger)hexNumber; 190 | } 191 | 192 | #pragma mark - 添加视图的手势 193 | - (UIView * _Nonnull (^)(void (^ _Nonnull)(id _Nonnull)))gyGestureTap{ 194 | return [self gyGesture:UITapGestureRecognizer.new]; 195 | } 196 | 197 | - (UIView * _Nonnull (^)(void (^ _Nonnull)(id _Nonnull)))gyGestureLongPress{ 198 | return [self gyGesture:UILongPressGestureRecognizer.new]; 199 | } 200 | 201 | - (UIView * _Nonnull (^)(NSInteger))gyGestureLongPressDuratime{ 202 | return ^(NSInteger duration){ 203 | NSArray *gestureArray = self.gestureRecognizers; 204 | __block UILongPressGestureRecognizer *gesture; 205 | [gestureArray enumerateObjectsUsingBlock:^(UIGestureRecognizer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 206 | if ([obj isKindOfClass:UILongPressGestureRecognizer.class]) { 207 | gesture = (UILongPressGestureRecognizer *)obj; 208 | } 209 | }]; 210 | gesture.minimumPressDuration = duration; 211 | return self; 212 | }; 213 | } 214 | 215 | - (UIView * _Nonnull (^)(void (^ _Nonnull)(id _Nonnull)))gyGesture:(UIGestureRecognizer *)gesture{ 216 | return ^(void (^block)(id sender)){ 217 | GYGestureTarget *target = [[GYGestureTarget alloc] initWithBlock:block]; 218 | [gesture addTarget:target action:@selector(gestureTap:)]; 219 | if ([gesture isKindOfClass:UILongPressGestureRecognizer.class]) { 220 | UILongPressGestureRecognizer *longPress = (UILongPressGestureRecognizer *)gesture; 221 | longPress.minimumPressDuration = 3; 222 | } 223 | self.userInteractionEnabled = YES; 224 | [self addGestureRecognizer:gesture]; 225 | [self.gyTargets addObject:target]; 226 | return self; 227 | }; 228 | } 229 | 230 | #pragma mark - 设置属性 231 | - (NSMutableArray *)gyTargets{ 232 | NSMutableArray *array = objc_getAssociatedObject(self, &GESTURETARGETKEY); 233 | if (!array) { 234 | array = NSMutableArray.new; 235 | objc_setAssociatedObject(self, &GESTURETARGETKEY, array, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 236 | } 237 | return array; 238 | } 239 | 240 | - (CGFloat)radius{ 241 | return (CGFloat)[objc_getAssociatedObject(self, &RADIUSKEY) floatValue]; 242 | } 243 | 244 | - (void)setRadius:(CGFloat)radius{ 245 | objc_setAssociatedObject(self, &RADIUSKEY, @(radius), OBJC_ASSOCIATION_ASSIGN); 246 | } 247 | 248 | - (UIRectCorner)corner{ 249 | return (NSInteger)[objc_getAssociatedObject(self, &CORNERKEY) integerValue]; 250 | } 251 | 252 | - (void)setCorner:(UIRectCorner)corner{ 253 | objc_setAssociatedObject(self, &CORNERKEY, @(corner), OBJC_ASSOCIATION_ASSIGN); 254 | } 255 | 256 | - (UIBezierPath *)bezierPath{ 257 | return objc_getAssociatedObject(self, &BEZIERPATHKEY); 258 | } 259 | 260 | - (void)setBezierPath:(UIBezierPath *)bezierPath{ 261 | objc_setAssociatedObject(self, &BEZIERPATHKEY, bezierPath, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 262 | } 263 | 264 | - (CGFloat)borderWidth{ 265 | return [objc_getAssociatedObject(self, &BORDERWIDTHKEY) floatValue]; 266 | } 267 | 268 | - (void)setBorderWidth:(CGFloat)borderWidth{ 269 | objc_setAssociatedObject(self, &BORDERWIDTHKEY, @(borderWidth), OBJC_ASSOCIATION_ASSIGN); 270 | } 271 | 272 | - (UIColor *)borderColor{ 273 | return objc_getAssociatedObject(self, &BORDERCOLORKEY); 274 | } 275 | 276 | - (void)setBorderColor:(UIColor *)borderColor{ 277 | objc_setAssociatedObject(self, &BORDERCOLORKEY, borderColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 278 | } 279 | 280 | #pragma mark - view的frame属性 281 | - (CGFloat)gyX{ 282 | return self.frame.origin.x; 283 | } 284 | - (void)setGyX:(CGFloat)gyX{ 285 | CGRect rect = self.frame; 286 | rect.origin.x = gyX; 287 | self.frame = rect; 288 | } 289 | 290 | - (CGFloat)gyY{ 291 | return self.frame.origin.y; 292 | } 293 | - (void)setGyY:(CGFloat)gyY{ 294 | CGRect rect = self.frame; 295 | rect.origin.y = gyY; 296 | self.frame = rect; 297 | } 298 | 299 | - (CGFloat)gyWidth{ 300 | return self.frame.size.width; 301 | } 302 | - (void)setGyWidth:(CGFloat)gyWidth{ 303 | CGRect rect = self.frame; 304 | rect.size.width = gyWidth; 305 | self.frame = rect; 306 | } 307 | 308 | - (CGFloat)gyHeight{ 309 | return self.frame.size.height; 310 | } 311 | - (void)setGyHeight:(CGFloat)gyHeight{ 312 | CGRect rect = self.frame; 313 | rect.size.height = gyHeight; 314 | self.frame = rect; 315 | } 316 | 317 | - (CGFloat)gyCenterX{ 318 | return self.frame.size.width / 2; 319 | } 320 | 321 | - (void)setGyCenterX:(CGFloat)gyCenterX{ 322 | CGRect rect = self.frame; 323 | rect.origin.x = gyCenterX - self.frame.size.width / 2; 324 | self.frame = rect; 325 | } 326 | 327 | - (CGFloat)gyCenterY{ 328 | return self.frame.size.height / 2; 329 | } 330 | 331 | - (void)setGyCenterY:(CGFloat)gyCenterY{ 332 | CGRect rect = self.frame; 333 | rect.origin.y = gyCenterY - self.frame.size.width / 2; 334 | self.frame = rect; 335 | } 336 | 337 | @end 338 | -------------------------------------------------------------------------------- /GYBaseViewCategory.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 26064F91230A7D0B0098374F /* Speak.m in Sources */ = {isa = PBXBuildFile; fileRef = 26064F90230A7D0B0098374F /* Speak.m */; }; 11 | 2628B91222F802520046D847 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2628B91122F802520046D847 /* Default-568h@2x.png */; }; 12 | 263EBD6822F96F53001BB93A /* UIImageView+GYConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 263EBD6722F96F53001BB93A /* UIImageView+GYConfig.m */; }; 13 | 26C55CCC22F6C05100D36C94 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 26C55CCB22F6C05100D36C94 /* AppDelegate.m */; }; 14 | 26C55CCF22F6C05100D36C94 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 26C55CCE22F6C05100D36C94 /* ViewController.m */; }; 15 | 26C55CD222F6C05100D36C94 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 26C55CD022F6C05100D36C94 /* Main.storyboard */; }; 16 | 26C55CD422F6C05600D36C94 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 26C55CD322F6C05600D36C94 /* Assets.xcassets */; }; 17 | 26C55CD722F6C05600D36C94 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 26C55CD522F6C05600D36C94 /* LaunchScreen.storyboard */; }; 18 | 26C55CDA22F6C05600D36C94 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 26C55CD922F6C05600D36C94 /* main.m */; }; 19 | 26C55CE822F6C09400D36C94 /* UIView+GYConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 26C55CE122F6C09400D36C94 /* UIView+GYConfig.m */; }; 20 | 26C55CE922F6C09400D36C94 /* UILabel+GYConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 26C55CE622F6C09400D36C94 /* UILabel+GYConfig.m */; }; 21 | 26C55CEA22F6C09400D36C94 /* UIButton+GYConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 26C55CE722F6C09400D36C94 /* UIButton+GYConfig.m */; }; 22 | 26C55CED22F6CFB800D36C94 /* UITextField+GYConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 26C55CEC22F6CFB800D36C94 /* UITextField+GYConfig.m */; }; 23 | 26C55CF022F6D16200D36C94 /* UITextView+GYConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 26C55CEF22F6D16200D36C94 /* UITextView+GYConfig.m */; }; 24 | 26E4D1EB22FA6F77006C8C14 /* AViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 26E4D1EA22FA6F77006C8C14 /* AViewController.m */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 26064F8F230A7D0B0098374F /* Speak.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Speak.h; sourceTree = ""; }; 29 | 26064F90230A7D0B0098374F /* Speak.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Speak.m; sourceTree = ""; }; 30 | 2628B91122F802520046D847 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 31 | 263EBD6622F96F53001BB93A /* UIImageView+GYConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImageView+GYConfig.h"; sourceTree = ""; }; 32 | 263EBD6722F96F53001BB93A /* UIImageView+GYConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+GYConfig.m"; sourceTree = ""; }; 33 | 26C55CC722F6C05100D36C94 /* GYBaseViewCategory.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GYBaseViewCategory.app; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | 26C55CCA22F6C05100D36C94 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | 26C55CCB22F6C05100D36C94 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | 26C55CCD22F6C05100D36C94 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 37 | 26C55CCE22F6C05100D36C94 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 38 | 26C55CD122F6C05100D36C94 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 39 | 26C55CD322F6C05600D36C94 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 40 | 26C55CD622F6C05600D36C94 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 41 | 26C55CD822F6C05600D36C94 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | 26C55CD922F6C05600D36C94 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 43 | 26C55CE122F6C09400D36C94 /* UIView+GYConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+GYConfig.m"; sourceTree = ""; }; 44 | 26C55CE222F6C09400D36C94 /* UILabel+GYConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UILabel+GYConfig.h"; sourceTree = ""; }; 45 | 26C55CE322F6C09400D36C94 /* UIButton+GYConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+GYConfig.h"; sourceTree = ""; }; 46 | 26C55CE422F6C09400D36C94 /* GYBaseViewHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GYBaseViewHeader.h; sourceTree = ""; }; 47 | 26C55CE522F6C09400D36C94 /* UIView+GYConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+GYConfig.h"; sourceTree = ""; }; 48 | 26C55CE622F6C09400D36C94 /* UILabel+GYConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UILabel+GYConfig.m"; sourceTree = ""; }; 49 | 26C55CE722F6C09400D36C94 /* UIButton+GYConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIButton+GYConfig.m"; sourceTree = ""; }; 50 | 26C55CEB22F6CFB800D36C94 /* UITextField+GYConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UITextField+GYConfig.h"; sourceTree = ""; }; 51 | 26C55CEC22F6CFB800D36C94 /* UITextField+GYConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UITextField+GYConfig.m"; sourceTree = ""; }; 52 | 26C55CEE22F6D16200D36C94 /* UITextView+GYConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UITextView+GYConfig.h"; sourceTree = ""; }; 53 | 26C55CEF22F6D16200D36C94 /* UITextView+GYConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UITextView+GYConfig.m"; sourceTree = ""; }; 54 | 26E4D1E922FA6F77006C8C14 /* AViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AViewController.h; sourceTree = ""; }; 55 | 26E4D1EA22FA6F77006C8C14 /* AViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AViewController.m; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | 26C55CC422F6C05100D36C94 /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | 262DC913233329C200614D3D /* Object */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | ); 73 | path = Object; 74 | sourceTree = ""; 75 | }; 76 | 26C55CBE22F6C05100D36C94 = { 77 | isa = PBXGroup; 78 | children = ( 79 | 2628B91122F802520046D847 /* Default-568h@2x.png */, 80 | 26C55CC922F6C05100D36C94 /* GYBaseViewCategory */, 81 | 26C55CC822F6C05100D36C94 /* Products */, 82 | ); 83 | sourceTree = ""; 84 | }; 85 | 26C55CC822F6C05100D36C94 /* Products */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 26C55CC722F6C05100D36C94 /* GYBaseViewCategory.app */, 89 | ); 90 | name = Products; 91 | sourceTree = ""; 92 | }; 93 | 26C55CC922F6C05100D36C94 /* GYBaseViewCategory */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 262DC913233329C200614D3D /* Object */, 97 | 26C55CE022F6C09400D36C94 /* View */, 98 | 26C55CCA22F6C05100D36C94 /* AppDelegate.h */, 99 | 26C55CCB22F6C05100D36C94 /* AppDelegate.m */, 100 | 26C55CCD22F6C05100D36C94 /* ViewController.h */, 101 | 26C55CCE22F6C05100D36C94 /* ViewController.m */, 102 | 26E4D1E922FA6F77006C8C14 /* AViewController.h */, 103 | 26E4D1EA22FA6F77006C8C14 /* AViewController.m */, 104 | 26C55CD022F6C05100D36C94 /* Main.storyboard */, 105 | 26C55CD322F6C05600D36C94 /* Assets.xcassets */, 106 | 26C55CD522F6C05600D36C94 /* LaunchScreen.storyboard */, 107 | 26C55CD822F6C05600D36C94 /* Info.plist */, 108 | 26C55CD922F6C05600D36C94 /* main.m */, 109 | 26064F8F230A7D0B0098374F /* Speak.h */, 110 | 26064F90230A7D0B0098374F /* Speak.m */, 111 | ); 112 | path = GYBaseViewCategory; 113 | sourceTree = ""; 114 | }; 115 | 26C55CE022F6C09400D36C94 /* View */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 26C55CE422F6C09400D36C94 /* GYBaseViewHeader.h */, 119 | 26C55CE322F6C09400D36C94 /* UIButton+GYConfig.h */, 120 | 26C55CE722F6C09400D36C94 /* UIButton+GYConfig.m */, 121 | 26C55CE222F6C09400D36C94 /* UILabel+GYConfig.h */, 122 | 26C55CE622F6C09400D36C94 /* UILabel+GYConfig.m */, 123 | 26C55CE522F6C09400D36C94 /* UIView+GYConfig.h */, 124 | 26C55CE122F6C09400D36C94 /* UIView+GYConfig.m */, 125 | 26C55CEB22F6CFB800D36C94 /* UITextField+GYConfig.h */, 126 | 26C55CEC22F6CFB800D36C94 /* UITextField+GYConfig.m */, 127 | 26C55CEE22F6D16200D36C94 /* UITextView+GYConfig.h */, 128 | 26C55CEF22F6D16200D36C94 /* UITextView+GYConfig.m */, 129 | 263EBD6622F96F53001BB93A /* UIImageView+GYConfig.h */, 130 | 263EBD6722F96F53001BB93A /* UIImageView+GYConfig.m */, 131 | ); 132 | path = View; 133 | sourceTree = ""; 134 | }; 135 | /* End PBXGroup section */ 136 | 137 | /* Begin PBXNativeTarget section */ 138 | 26C55CC622F6C05100D36C94 /* GYBaseViewCategory */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = 26C55CDD22F6C05600D36C94 /* Build configuration list for PBXNativeTarget "GYBaseViewCategory" */; 141 | buildPhases = ( 142 | 26C55CC322F6C05100D36C94 /* Sources */, 143 | 26C55CC422F6C05100D36C94 /* Frameworks */, 144 | 26C55CC522F6C05100D36C94 /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | ); 150 | name = GYBaseViewCategory; 151 | productName = ViewCatagory; 152 | productReference = 26C55CC722F6C05100D36C94 /* GYBaseViewCategory.app */; 153 | productType = "com.apple.product-type.application"; 154 | }; 155 | /* End PBXNativeTarget section */ 156 | 157 | /* Begin PBXProject section */ 158 | 26C55CBF22F6C05100D36C94 /* Project object */ = { 159 | isa = PBXProject; 160 | attributes = { 161 | LastUpgradeCheck = 1030; 162 | ORGANIZATIONNAME = "Zhiyuan Gao"; 163 | TargetAttributes = { 164 | 26C55CC622F6C05100D36C94 = { 165 | CreatedOnToolsVersion = 10.3; 166 | }; 167 | }; 168 | }; 169 | buildConfigurationList = 26C55CC222F6C05100D36C94 /* Build configuration list for PBXProject "GYBaseViewCategory" */; 170 | compatibilityVersion = "Xcode 9.3"; 171 | developmentRegion = en; 172 | hasScannedForEncodings = 0; 173 | knownRegions = ( 174 | en, 175 | Base, 176 | ); 177 | mainGroup = 26C55CBE22F6C05100D36C94; 178 | productRefGroup = 26C55CC822F6C05100D36C94 /* Products */; 179 | projectDirPath = ""; 180 | projectRoot = ""; 181 | targets = ( 182 | 26C55CC622F6C05100D36C94 /* GYBaseViewCategory */, 183 | ); 184 | }; 185 | /* End PBXProject section */ 186 | 187 | /* Begin PBXResourcesBuildPhase section */ 188 | 26C55CC522F6C05100D36C94 /* Resources */ = { 189 | isa = PBXResourcesBuildPhase; 190 | buildActionMask = 2147483647; 191 | files = ( 192 | 26C55CD722F6C05600D36C94 /* LaunchScreen.storyboard in Resources */, 193 | 2628B91222F802520046D847 /* Default-568h@2x.png in Resources */, 194 | 26C55CD422F6C05600D36C94 /* Assets.xcassets in Resources */, 195 | 26C55CD222F6C05100D36C94 /* Main.storyboard in Resources */, 196 | ); 197 | runOnlyForDeploymentPostprocessing = 0; 198 | }; 199 | /* End PBXResourcesBuildPhase section */ 200 | 201 | /* Begin PBXSourcesBuildPhase section */ 202 | 26C55CC322F6C05100D36C94 /* Sources */ = { 203 | isa = PBXSourcesBuildPhase; 204 | buildActionMask = 2147483647; 205 | files = ( 206 | 26C55CED22F6CFB800D36C94 /* UITextField+GYConfig.m in Sources */, 207 | 26C55CCF22F6C05100D36C94 /* ViewController.m in Sources */, 208 | 26C55CEA22F6C09400D36C94 /* UIButton+GYConfig.m in Sources */, 209 | 26C55CE822F6C09400D36C94 /* UIView+GYConfig.m in Sources */, 210 | 26C55CDA22F6C05600D36C94 /* main.m in Sources */, 211 | 263EBD6822F96F53001BB93A /* UIImageView+GYConfig.m in Sources */, 212 | 26064F91230A7D0B0098374F /* Speak.m in Sources */, 213 | 26E4D1EB22FA6F77006C8C14 /* AViewController.m in Sources */, 214 | 26C55CCC22F6C05100D36C94 /* AppDelegate.m in Sources */, 215 | 26C55CE922F6C09400D36C94 /* UILabel+GYConfig.m in Sources */, 216 | 26C55CF022F6D16200D36C94 /* UITextView+GYConfig.m in Sources */, 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | }; 220 | /* End PBXSourcesBuildPhase section */ 221 | 222 | /* Begin PBXVariantGroup section */ 223 | 26C55CD022F6C05100D36C94 /* Main.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 26C55CD122F6C05100D36C94 /* Base */, 227 | ); 228 | name = Main.storyboard; 229 | sourceTree = ""; 230 | }; 231 | 26C55CD522F6C05600D36C94 /* LaunchScreen.storyboard */ = { 232 | isa = PBXVariantGroup; 233 | children = ( 234 | 26C55CD622F6C05600D36C94 /* Base */, 235 | ); 236 | name = LaunchScreen.storyboard; 237 | sourceTree = ""; 238 | }; 239 | /* End PBXVariantGroup section */ 240 | 241 | /* Begin XCBuildConfiguration section */ 242 | 26C55CDB22F6C05600D36C94 /* Debug */ = { 243 | isa = XCBuildConfiguration; 244 | buildSettings = { 245 | ALWAYS_SEARCH_USER_PATHS = NO; 246 | CLANG_ANALYZER_NONNULL = YES; 247 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 248 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 249 | CLANG_CXX_LIBRARY = "libc++"; 250 | CLANG_ENABLE_MODULES = YES; 251 | CLANG_ENABLE_OBJC_ARC = YES; 252 | CLANG_ENABLE_OBJC_WEAK = YES; 253 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 254 | CLANG_WARN_BOOL_CONVERSION = YES; 255 | CLANG_WARN_COMMA = YES; 256 | CLANG_WARN_CONSTANT_CONVERSION = YES; 257 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 258 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 259 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 260 | CLANG_WARN_EMPTY_BODY = YES; 261 | CLANG_WARN_ENUM_CONVERSION = YES; 262 | CLANG_WARN_INFINITE_RECURSION = YES; 263 | CLANG_WARN_INT_CONVERSION = YES; 264 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 265 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 266 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 267 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 268 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 269 | CLANG_WARN_STRICT_PROTOTYPES = YES; 270 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 271 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 272 | CLANG_WARN_UNREACHABLE_CODE = YES; 273 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 274 | CODE_SIGN_IDENTITY = "iPhone Developer"; 275 | COPY_PHASE_STRIP = NO; 276 | DEBUG_INFORMATION_FORMAT = dwarf; 277 | ENABLE_STRICT_OBJC_MSGSEND = YES; 278 | ENABLE_TESTABILITY = YES; 279 | GCC_C_LANGUAGE_STANDARD = gnu11; 280 | GCC_DYNAMIC_NO_PIC = NO; 281 | GCC_NO_COMMON_BLOCKS = YES; 282 | GCC_OPTIMIZATION_LEVEL = 0; 283 | GCC_PREPROCESSOR_DEFINITIONS = ( 284 | "DEBUG=1", 285 | "$(inherited)", 286 | ); 287 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 288 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 289 | GCC_WARN_UNDECLARED_SELECTOR = YES; 290 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 291 | GCC_WARN_UNUSED_FUNCTION = YES; 292 | GCC_WARN_UNUSED_VARIABLE = YES; 293 | IPHONEOS_DEPLOYMENT_TARGET = 12.4; 294 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 295 | MTL_FAST_MATH = YES; 296 | ONLY_ACTIVE_ARCH = YES; 297 | SDKROOT = iphoneos; 298 | }; 299 | name = Debug; 300 | }; 301 | 26C55CDC22F6C05600D36C94 /* Release */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | ALWAYS_SEARCH_USER_PATHS = NO; 305 | CLANG_ANALYZER_NONNULL = YES; 306 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 307 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 308 | CLANG_CXX_LIBRARY = "libc++"; 309 | CLANG_ENABLE_MODULES = YES; 310 | CLANG_ENABLE_OBJC_ARC = YES; 311 | CLANG_ENABLE_OBJC_WEAK = YES; 312 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 313 | CLANG_WARN_BOOL_CONVERSION = YES; 314 | CLANG_WARN_COMMA = YES; 315 | CLANG_WARN_CONSTANT_CONVERSION = YES; 316 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 317 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 318 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 319 | CLANG_WARN_EMPTY_BODY = YES; 320 | CLANG_WARN_ENUM_CONVERSION = YES; 321 | CLANG_WARN_INFINITE_RECURSION = YES; 322 | CLANG_WARN_INT_CONVERSION = YES; 323 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 324 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 325 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 326 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 327 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 328 | CLANG_WARN_STRICT_PROTOTYPES = YES; 329 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 330 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 331 | CLANG_WARN_UNREACHABLE_CODE = YES; 332 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 333 | CODE_SIGN_IDENTITY = "iPhone Developer"; 334 | COPY_PHASE_STRIP = NO; 335 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 336 | ENABLE_NS_ASSERTIONS = NO; 337 | ENABLE_STRICT_OBJC_MSGSEND = YES; 338 | GCC_C_LANGUAGE_STANDARD = gnu11; 339 | GCC_NO_COMMON_BLOCKS = YES; 340 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 341 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 342 | GCC_WARN_UNDECLARED_SELECTOR = YES; 343 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 344 | GCC_WARN_UNUSED_FUNCTION = YES; 345 | GCC_WARN_UNUSED_VARIABLE = YES; 346 | IPHONEOS_DEPLOYMENT_TARGET = 12.4; 347 | MTL_ENABLE_DEBUG_INFO = NO; 348 | MTL_FAST_MATH = YES; 349 | SDKROOT = iphoneos; 350 | VALIDATE_PRODUCT = YES; 351 | }; 352 | name = Release; 353 | }; 354 | 26C55CDE22F6C05600D36C94 /* Debug */ = { 355 | isa = XCBuildConfiguration; 356 | buildSettings = { 357 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 358 | CODE_SIGN_STYLE = Automatic; 359 | CURRENT_PROJECT_VERSION = 5; 360 | DEVELOPMENT_TEAM = X25H8723Q8; 361 | INFOPLIST_FILE = GYBaseViewCategory/Info.plist; 362 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 363 | LD_RUNPATH_SEARCH_PATHS = ( 364 | "$(inherited)", 365 | "@executable_path/Frameworks", 366 | ); 367 | MARKETING_VERSION = 0.1.0; 368 | PRODUCT_BUNDLE_IDENTIFIER = com.gzy.ViewCatagory; 369 | PRODUCT_NAME = "$(TARGET_NAME)"; 370 | TARGETED_DEVICE_FAMILY = "1,2"; 371 | }; 372 | name = Debug; 373 | }; 374 | 26C55CDF22F6C05600D36C94 /* Release */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 378 | CODE_SIGN_STYLE = Automatic; 379 | CURRENT_PROJECT_VERSION = 5; 380 | DEVELOPMENT_TEAM = X25H8723Q8; 381 | INFOPLIST_FILE = GYBaseViewCategory/Info.plist; 382 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 383 | LD_RUNPATH_SEARCH_PATHS = ( 384 | "$(inherited)", 385 | "@executable_path/Frameworks", 386 | ); 387 | MARKETING_VERSION = 0.1.0; 388 | PRODUCT_BUNDLE_IDENTIFIER = com.gzy.ViewCatagory; 389 | PRODUCT_NAME = "$(TARGET_NAME)"; 390 | TARGETED_DEVICE_FAMILY = "1,2"; 391 | }; 392 | name = Release; 393 | }; 394 | /* End XCBuildConfiguration section */ 395 | 396 | /* Begin XCConfigurationList section */ 397 | 26C55CC222F6C05100D36C94 /* Build configuration list for PBXProject "GYBaseViewCategory" */ = { 398 | isa = XCConfigurationList; 399 | buildConfigurations = ( 400 | 26C55CDB22F6C05600D36C94 /* Debug */, 401 | 26C55CDC22F6C05600D36C94 /* Release */, 402 | ); 403 | defaultConfigurationIsVisible = 0; 404 | defaultConfigurationName = Release; 405 | }; 406 | 26C55CDD22F6C05600D36C94 /* Build configuration list for PBXNativeTarget "GYBaseViewCategory" */ = { 407 | isa = XCConfigurationList; 408 | buildConfigurations = ( 409 | 26C55CDE22F6C05600D36C94 /* Debug */, 410 | 26C55CDF22F6C05600D36C94 /* Release */, 411 | ); 412 | defaultConfigurationIsVisible = 0; 413 | defaultConfigurationName = Release; 414 | }; 415 | /* End XCConfigurationList section */ 416 | }; 417 | rootObject = 26C55CBF22F6C05100D36C94 /* Project object */; 418 | } 419 | --------------------------------------------------------------------------------