├── .DS_Store ├── LICENSE ├── README.md ├── ShapeButton.podspec ├── ShapeButton ├── .DS_Store ├── Assets │ ├── .DS_Store │ └── button.xcassets │ │ ├── Contents.json │ │ ├── virtual_control_h.imageset │ │ ├── Contents.json │ │ ├── tv_voice@2x.png │ │ └── tv_voice@3x.png │ │ ├── virtual_control_number.imageset │ │ ├── Contents.json │ │ ├── tv_numberbtn@2x.png │ │ └── tv_numberbtn@3x.png │ │ ├── virtual_control_rect.imageset │ │ ├── 2@2x.png │ │ ├── 2@3x.png │ │ └── Contents.json │ │ ├── virtual_control_round.imageset │ │ ├── Contents.json │ │ ├── custom_annulus2.png │ │ └── custom_annulus2@2x.png │ │ ├── virtual_control_round_single.imageset │ │ ├── Contents.json │ │ ├── circle@2x.png │ │ └── circle@3x.png │ │ ├── virtual_control_setting.imageset │ │ ├── Contents.json │ │ ├── setting@2x.png │ │ └── setting@3x.png │ │ ├── virtual_control_switch.imageset │ │ ├── Contents.json │ │ ├── open@2x.png │ │ └── open@3x.png │ │ └── virtual_control_v.imageset │ │ ├── 1@2x.png │ │ ├── 1@3x.png │ │ └── Contents.json └── Classes │ ├── ZAShapeButton.h │ └── ZAShapeButton.m ├── ZAShapeButton.gif ├── ZAShapeButton.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── ZAShapeButton.xccheckout │ └── xcuserdata │ │ ├── zhuoapp.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── zhutc.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── zhuoapp.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── ZAShapeButton.xcscheme │ │ └── xcschememanagement.plist │ └── zhutc.xcuserdatad │ └── xcschemes │ ├── ZAShapeButton.xcscheme │ └── xcschememanagement.plist ├── ZAShapeButton ├── .DS_Store ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── .DS_Store │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Info.plist ├── ShapeButton │ ├── .DS_Store │ ├── Assets │ │ ├── .DS_Store │ │ └── button.xcassets │ │ │ ├── Contents.json │ │ │ ├── virtual_control_h.imageset │ │ │ ├── Contents.json │ │ │ ├── tv_voice@2x.png │ │ │ └── tv_voice@3x.png │ │ │ ├── virtual_control_number.imageset │ │ │ ├── Contents.json │ │ │ ├── tv_numberbtn@2x.png │ │ │ └── tv_numberbtn@3x.png │ │ │ ├── virtual_control_rect.imageset │ │ │ ├── 2@2x.png │ │ │ ├── 2@3x.png │ │ │ └── Contents.json │ │ │ ├── virtual_control_round.imageset │ │ │ ├── Contents.json │ │ │ ├── custom_annulus2.png │ │ │ └── custom_annulus2@2x.png │ │ │ ├── virtual_control_round_single.imageset │ │ │ ├── Contents.json │ │ │ ├── circle@2x.png │ │ │ └── circle@3x.png │ │ │ ├── virtual_control_setting.imageset │ │ │ ├── Contents.json │ │ │ ├── setting@2x.png │ │ │ └── setting@3x.png │ │ │ ├── virtual_control_switch.imageset │ │ │ ├── Contents.json │ │ │ ├── open@2x.png │ │ │ └── open@3x.png │ │ │ └── virtual_control_v.imageset │ │ │ ├── 1@2x.png │ │ │ ├── 1@3x.png │ │ │ └── Contents.json │ └── Classes │ │ ├── ZAShapeButton.h │ │ └── ZAShapeButton.m ├── ViewController.h ├── ViewController.m ├── ZAShapeButton.xcdatamodeld │ ├── .xccurrentversion │ └── ZAShapeButton.xcdatamodel │ │ └── contents └── main.m └── ZAShapeButtonTests ├── Info.plist └── ZAShapeButtonTests.m /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/.DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 chuting 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZAShapButton 2 | 不规则按钮,可以分别控制上下左右 3 | 4 | 5 | ![image](https://github.com/chuting/ZAShapButton/blob/master/ZAShapeButton.gif) 6 | 7 | 8 | ## Installation 9 | 10 | ZAColorChooseView is available through [CocoaPods](http://cocoapods.org). To install 11 | it, simply add the following line to your Podfile: 12 | 13 | ```ruby 14 | pod "ShapeButton" 15 | ``` 16 | 17 | ## Author 18 | 19 | chuting, 502353919@qq.com 20 | 21 | 22 | -------------------------------------------------------------------------------- /ShapeButton.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'ShapeButton' 3 | s.version = '1.0.1' 4 | 5 | s.summary = ' 这个是个sdk实现了灯具的收发指令以及指令拼接等功能' 6 | s.description = ' 这个是个sdk实现了灯具的收发指令以及指令拼接等功能, 这个是个sdk实现了灯具的收发指令以及指令拼接等功能 这个是个sdk实现了灯具的收发指令以及指令拼接等功能 这个是个sdk实现了灯具的收发指令以及指令拼接等功能 这个是个sdk实现了灯具的收发指令以及指令拼接等功能' 7 | 8 | 9 | s.homepage = 'https://github.com/chuting/ZAShapButton' 10 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' 11 | s.license = { :type => 'MIT', :file => 'LICENSE' } 12 | s.author = { 'chuting' => '502353919@qq.com' } 13 | s.source = { :git => 'https://github.com/chuting/ZAShapButton.git', :branch => 'master' } 14 | 15 | s.requires_arc = true 16 | # s.social_media_url = 'https://twitter.com/' 17 | 18 | s.ios.deployment_target = '8.0' 19 | s.source_files = 'ShapeButton/Classes/**/*' 20 | 21 | s.public_header_files = 'ShapeButton/Classes/**/*.h' 22 | s.resources = ['ShapeButton/Assets/button.xcassets',] 23 | 24 | 25 | s.frameworks = 'UIKit' 26 | 27 | 28 | 29 | end 30 | -------------------------------------------------------------------------------- /ShapeButton/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/.DS_Store -------------------------------------------------------------------------------- /ShapeButton/Assets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/.DS_Store -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_h.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tv_voice@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "tv_voice@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_h.imageset/tv_voice@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_h.imageset/tv_voice@2x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_h.imageset/tv_voice@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_h.imageset/tv_voice@3x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_number.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tv_numberbtn@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "tv_numberbtn@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_number.imageset/tv_numberbtn@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_number.imageset/tv_numberbtn@2x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_number.imageset/tv_numberbtn@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_number.imageset/tv_numberbtn@3x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_rect.imageset/2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_rect.imageset/2@2x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_rect.imageset/2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_rect.imageset/2@3x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_rect.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "2@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "2@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_round.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "custom_annulus2@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "custom_annulus2.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_round.imageset/custom_annulus2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_round.imageset/custom_annulus2.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_round.imageset/custom_annulus2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_round.imageset/custom_annulus2@2x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_round_single.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "circle@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "circle@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_round_single.imageset/circle@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_round_single.imageset/circle@2x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_round_single.imageset/circle@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_round_single.imageset/circle@3x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_setting.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "setting@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "setting@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_setting.imageset/setting@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_setting.imageset/setting@2x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_setting.imageset/setting@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_setting.imageset/setting@3x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_switch.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "open@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "open@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_switch.imageset/open@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_switch.imageset/open@2x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_switch.imageset/open@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_switch.imageset/open@3x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_v.imageset/1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_v.imageset/1@2x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_v.imageset/1@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ShapeButton/Assets/button.xcassets/virtual_control_v.imageset/1@3x.png -------------------------------------------------------------------------------- /ShapeButton/Assets/button.xcassets/virtual_control_v.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "1@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "1@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ShapeButton/Classes/ZAShapeButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZAShapeButton.h 3 | // OppleOnline 4 | // 5 | // Created by zhuoapp on 15/6/3. 6 | // Copyright (c) 2015年 zhuoapp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | typedef enum ButtonType{ 14 | 15 | /** 16 | * 圆形五个按钮 上下左右 中心 17 | */ 18 | ButtonType_Round=0, 19 | /** 20 | * 单个圆形按钮 只响应 SelectButtonPosition_Center 21 | */ 22 | ButtonType_Round_Single, 23 | /** 24 | * 圆角按钮 只响应 SelectButtonPosition_Center 25 | */ 26 | ButtonType_Rect, 27 | /** 28 | * 竖加减 只响应 SelectButtonPosition_Buttom SelectButtonPosition_Top, 29 | */ 30 | ButtonType_V_PlusAndMin, 31 | 32 | /** 33 | * 横加减 只响应 SelectButtonPosition_Right SelectButtonPosition_Left, 34 | */ 35 | ButtonType_H_PlusAndMin, 36 | 37 | }ButtonType; 38 | 39 | 40 | 41 | 42 | typedef enum ButtonClickType 43 | { 44 | 45 | //手势抬起响应 46 | ButtonClickType_TouchUpInside=0, 47 | 48 | //长按0.5s响应 49 | ButtonClickType_LongPress, 50 | 51 | 52 | }ButtonClickType; 53 | 54 | 55 | 56 | typedef enum SelectButtonPosition{ 57 | 58 | SelectButtonPosition_Top =1, 59 | SelectButtonPosition_Right =1<<1 , 60 | SelectButtonPosition_Buttom =1<<2 , 61 | SelectButtonPosition_Left =1<<3, 62 | SelectButtonPosition_Center =1<<4, 63 | 64 | }SelectButtonPosition; 65 | 66 | @interface ZAShapeButton : UIImageView 67 | { 68 | 69 | 70 | // NSArray *pathArray; 71 | NSMutableArray *layerArray; 72 | SEL touchAction; 73 | SEL longPressAction; 74 | id handel; 75 | 76 | UIGestureRecognizerState responseState; 77 | 78 | 79 | ButtonType buttonType; 80 | 81 | UILabel *titleLabel; 82 | 83 | 84 | NSTimer *longPressTimer; 85 | 86 | 87 | UILongPressGestureRecognizer *longPressGestureRecognizer; 88 | 89 | 90 | //长按手势未执行 91 | BOOL longPressNotComplete ; 92 | } 93 | 94 | /** 95 | * 获取选中位置 96 | */ 97 | @property (nonatomic) enum SelectButtonPosition selectButtonPosition; 98 | 99 | 100 | /** 101 | * 初始化button 102 | * 103 | * @param frame <#frame description#> 104 | * @param type button 类型 105 | * 106 | * @return <#return value description#> 107 | */ 108 | -(instancetype)initWithFrame:(CGRect)frame ButtonType:(ButtonType)type; 109 | 110 | 111 | -(void)addTarget:(id)target action:(SEL)action forResponseState:(ButtonClickType)state; 112 | 113 | 114 | /** 115 | * 设置响应位置, 116 | * 117 | * @param position 可以传多个参数 118 | */ 119 | -(void)setResponsePosition:(SelectButtonPosition)position; 120 | 121 | 122 | -(void)setTitle:(NSString *)title; 123 | 124 | @end 125 | -------------------------------------------------------------------------------- /ShapeButton/Classes/ZAShapeButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZAShapeButton.m 3 | // OppleOnline 4 | // 5 | // Created by zhuoapp on 15/6/3. 6 | // Copyright (c) 2015年 zhuoapp. All rights reserved. 7 | // 8 | 9 | #import "ZAShapeButton.h" 10 | 11 | 12 | #define PathKey @"path" 13 | #define PositionKey @"position" 14 | #define PathDic(path,position) [NSDictionary dictionaryWithObjectsAndKeys:path,@"path",position,@"position", nil] 15 | #define OffSet 2.5 16 | @interface ZAShapeButton() 17 | 18 | @property (nonatomic) NSMutableArray *pathArray; 19 | @end 20 | 21 | @implementation ZAShapeButton 22 | @synthesize selectButtonPosition; 23 | /* 24 | // Only override drawRect: if you perform custom drawing. 25 | // An empty implementation adversely affects performance during animation. 26 | - (void)drawRect:(CGRect)rect { 27 | // Drawing code 28 | } 29 | */ 30 | 31 | 32 | 33 | -(instancetype)initWithFrame:(CGRect)frame ButtonType:(ButtonType)type 34 | { 35 | self=[super initWithFrame:frame]; 36 | if (!self) { 37 | return nil; 38 | } 39 | buttonType=type; 40 | titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0,CGRectGetWidth(frame), CGRectGetHeight(frame))]; 41 | titleLabel.backgroundColor=[UIColor clearColor]; 42 | titleLabel.textColor=[UIColor colorWithRed:159/255.0 green:159/255.0 blue:167/255.0 alpha:1]; 43 | titleLabel.font=[UIFont systemFontOfSize:15]; 44 | titleLabel.textAlignment=NSTextAlignmentCenter; 45 | [self addSubview:titleLabel]; 46 | 47 | self.userInteractionEnabled=YES; 48 | 49 | longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressGesture:)]; 50 | longPressGestureRecognizer.minimumPressDuration=0.05; 51 | [self addGestureRecognizer:longPressGestureRecognizer]; 52 | 53 | switch (type) { 54 | case ButtonType_Rect: 55 | self.image=[UIImage imageNamed:@"virtual_control_rect"] ; 56 | break; 57 | case ButtonType_Round_Single: 58 | self.image=[UIImage imageNamed:@"virtual_control_round_single"]; 59 | break; 60 | case ButtonType_Round: 61 | self.image=[UIImage imageNamed:@"virtual_control_round"]; 62 | break; 63 | case ButtonType_H_PlusAndMin: 64 | self.image=[UIImage imageNamed:@"virtual_control_h"] ; 65 | break; 66 | case ButtonType_V_PlusAndMin: 67 | self.image=[UIImage imageNamed:@"virtual_control_v"]; 68 | break; 69 | default: 70 | break; 71 | } 72 | return self; 73 | } 74 | 75 | 76 | 77 | -(void)setImage:(UIImage *)image 78 | { 79 | [super setImage:image]; 80 | self.frame=CGRectMake(CGRectGetMinX(self.frame), CGRectGetMinY(self.frame), self.image.size.width, self.image.size.height); 81 | titleLabel.frame=CGRectMake(0, 0,CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)); 82 | 83 | } 84 | #pragma mark - 设置标题 85 | -(void)setTitle:(NSString *)title 86 | { 87 | titleLabel.text=title; 88 | } 89 | 90 | 91 | #pragma mark - 设置响应位置 92 | -(void)setResponsePosition:(SelectButtonPosition)position 93 | { 94 | if (!_pathArray) { 95 | _pathArray=[[NSMutableArray alloc]init]; 96 | }else{ 97 | [_pathArray removeAllObjects]; 98 | } 99 | 100 | if (buttonType==ButtonType_H_PlusAndMin) { 101 | if (position & SelectButtonPosition_Left) { 102 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPosition_Left]]; 103 | } 104 | 105 | if (position & SelectButtonPosition_Right) { 106 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPosition_Right]]; 107 | } 108 | } 109 | 110 | if (buttonType==ButtonType_V_PlusAndMin) { 111 | if (position & SelectButtonPosition_Top) { 112 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPosition_Top]]; 113 | } 114 | if (position & SelectButtonPosition_Buttom) { 115 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPosition_Buttom]]; 116 | } 117 | } 118 | 119 | if (buttonType==ButtonType_Round) { 120 | if (position & SelectButtonPosition_Top) { 121 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPosition_Top]]; 122 | } 123 | if (position & SelectButtonPosition_Left) { 124 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPosition_Left]]; 125 | } 126 | if (position & SelectButtonPosition_Right) { 127 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPosition_Right]]; 128 | } 129 | if (position & SelectButtonPosition_Buttom) { 130 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPosition_Buttom]]; 131 | } 132 | if (position & SelectButtonPosition_Center) { 133 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPosition_Center]]; 134 | } 135 | } 136 | } 137 | 138 | #pragma mark - 获取路径数组 139 | -(NSMutableArray *)pathArray 140 | { 141 | if (!_pathArray) { 142 | _pathArray=[[NSMutableArray alloc]init]; 143 | switch (buttonType) { 144 | case ButtonType_H_PlusAndMin: 145 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPosition_Left]]; 146 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPosition_Right]]; 147 | break; 148 | case ButtonType_V_PlusAndMin: 149 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPosition_Top]]; 150 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPosition_Buttom]]; 151 | break; 152 | case ButtonType_Round: 153 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPosition_Left]]; 154 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPosition_Right]]; 155 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPosition_Top]]; 156 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPosition_Buttom]]; 157 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPosition_Center]]; 158 | break; 159 | case ButtonType_Round_Single: 160 | [_pathArray addObject:[self roundShap]]; 161 | break; 162 | case ButtonType_Rect: 163 | [_pathArray addObject:[self rectShap]]; 164 | break; 165 | default: 166 | break; 167 | } 168 | 169 | } 170 | return _pathArray; 171 | 172 | } 173 | 174 | 175 | 176 | #pragma mark - 添加响应事件 177 | -(void)addTarget:(id)target action:(SEL)action forResponseState:(ButtonClickType)state 178 | { 179 | handel=target; 180 | switch (state) { 181 | case ButtonClickType_LongPress: 182 | longPressAction=action; 183 | break; 184 | case ButtonClickType_TouchUpInside: 185 | touchAction=action; 186 | break; 187 | default: 188 | break; 189 | } 190 | } 191 | 192 | 193 | 194 | #pragma mark - 触摸事件执行 195 | - (void)longPressGesture:(UILongPressGestureRecognizer*)longGesture{ 196 | 197 | BOOL containsPoint=[self containsPoint:[longPressGestureRecognizer locationInView:self]]; 198 | NSInteger tag = [self indexOfPoint:[longPressGestureRecognizer locationInView:self]]; 199 | 200 | if (containsPoint) { 201 | if (!layerArray) { 202 | layerArray=[[NSMutableArray alloc]init]; 203 | for (NSDictionary *dic in self.pathArray) { 204 | UIBezierPath *path=[dic objectForKey:PathKey]; 205 | CAShapeLayer *maskLayer = [CAShapeLayer layer]; 206 | maskLayer.path = [path CGPath]; 207 | maskLayer.fillColor = [[UIColor colorWithWhite:0 alpha:0.2] CGColor]; 208 | maskLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)); 209 | [self.layer addSublayer:maskLayer]; 210 | [layerArray addObject:maskLayer]; 211 | } 212 | } 213 | } 214 | 215 | if (longGesture &&(longGesture.state==UIGestureRecognizerStateBegan||longGesture.state==UIGestureRecognizerStateChanged)) { 216 | if (!containsPoint){ 217 | return; 218 | } 219 | if (longGesture.state==UIGestureRecognizerStateBegan) { 220 | longPressNotComplete=YES; 221 | if (longPressAction!=nil) { 222 | //如果有长按执行事件,则初始化timer 223 | longPressTimer=[NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(longPressTimerOut) userInfo:nil repeats:NO]; 224 | } 225 | } 226 | 227 | [UIView animateWithDuration:0.2 animations:^{ 228 | for (NSInteger i=0; i2*M_PI?(startAngle-2.0*M_PI):startAngle; 377 | float endAngle=startAngle+1/2.0*M_PI; 378 | [bezierPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; 379 | CGPoint point; 380 | point.x=center.x+radius*sin(endAngle); 381 | point.y=center.x+radius*cos(endAngle); 382 | [bezierPath addLineToPoint:point]; 383 | [bezierPath addArcWithCenter:center radius:radius-width startAngle:endAngle endAngle:startAngle clockwise:NO]; 384 | 385 | point.x=center.x+radius*sin(startAngle); 386 | point.y=center.y+radius*cos(startAngle); 387 | 388 | [bezierPath addLineToPoint:point]; 389 | [bezierPath closePath]; 390 | 391 | return PathDic(bezierPath, [NSNumber numberWithInteger:position]); 392 | } 393 | 394 | 395 | 396 | #pragma mark - 整圆贝塞尔曲线 397 | -(NSDictionary *)roundShap{ 398 | 399 | return [self roundPathWithRadius:(CGRectGetWidth(self.frame)/2.0-OffSet) center:CGPointMake(CGRectGetWidth(self.frame)/2, CGRectGetHeight(self.frame)/2)]; 400 | 401 | } 402 | 403 | 404 | 405 | #pragma mark - 406 | -(NSDictionary *)roundPathWithRadius:(float)radius center:(CGPoint)center 407 | { 408 | UIBezierPath* bezierPath = [UIBezierPath bezierPath]; 409 | [bezierPath addArcWithCenter:center radius:radius startAngle:0 endAngle:2.0*M_PI clockwise:YES]; 410 | [bezierPath closePath]; 411 | 412 | return PathDic(bezierPath, [NSNumber numberWithInteger:SelectButtonPosition_Center]); 413 | } 414 | 415 | 416 | 417 | #pragma mark - 整圆贝塞尔曲线 418 | -(NSDictionary *)rectShap{ 419 | UIBezierPath* bezierPath = [UIBezierPath bezierPath]; 420 | 421 | float offset=OffSet; 422 | 423 | float radius= CGRectGetHeight(self.frame)/2-offset; 424 | float width=CGRectGetWidth(self.frame)-2*radius-offset*2; 425 | CGRect frame=self.frame; 426 | CGPoint center; 427 | float startAngle ; 428 | float endAngle; 429 | center.x= radius+offset; 430 | center.y=CGRectGetHeight(frame)/2.0; 431 | startAngle=M_PI/2.0; 432 | endAngle=3/2.0*M_PI; 433 | [bezierPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; 434 | 435 | CGPoint point; 436 | 437 | point.x=center.x+width; 438 | point.y=offset; 439 | [bezierPath addLineToPoint:point]; 440 | 441 | 442 | center.x=point.x; 443 | [bezierPath addArcWithCenter:center radius:radius startAngle:endAngle endAngle:startAngle clockwise:YES]; 444 | [bezierPath closePath]; 445 | 446 | return PathDic(bezierPath, [NSNumber numberWithInteger:SelectButtonPosition_Center]); 447 | } 448 | 449 | 450 | 451 | #pragma mark - 获取获取点在数组的位置 452 | -(NSInteger)indexOfPoint:(CGPoint)point 453 | { 454 | for (NSDictionary *path in self.pathArray) { 455 | if ([[path objectForKey:PathKey] containsPoint:point]) { 456 | return [self.pathArray indexOfObject:path]; 457 | break; 458 | } 459 | } 460 | return -1; 461 | } 462 | 463 | 464 | 465 | 466 | #pragma mark - 获取位置 467 | -(SelectButtonPosition)GetPositonWithTag:(NSInteger)tag 468 | { 469 | NSDictionary *path=[self.pathArray objectAtIndex:tag]; 470 | return [[path objectForKey:PositionKey] intValue]; 471 | 472 | } 473 | 474 | 475 | #pragma mark - 点是否在曲线内 476 | -(BOOL)containsPoint:(CGPoint)point 477 | { 478 | return ([self indexOfPoint:point]==-1?NO:YES); 479 | 480 | } 481 | 482 | 483 | 484 | @end 485 | -------------------------------------------------------------------------------- /ZAShapeButton.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton.gif -------------------------------------------------------------------------------- /ZAShapeButton.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 7329B4271E5313E500F33901 /* button.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7329B4231E5313E500F33901 /* button.xcassets */; }; 11 | 7329B4281E5313E500F33901 /* ZAShapeButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 7329B4261E5313E500F33901 /* ZAShapeButton.m */; }; 12 | 73ED65DC1B43DD76004B7402 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 73ED65DB1B43DD76004B7402 /* main.m */; }; 13 | 73ED65DF1B43DD76004B7402 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 73ED65DE1B43DD76004B7402 /* AppDelegate.m */; }; 14 | 73ED65E21B43DD76004B7402 /* ZAShapeButton.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 73ED65E01B43DD76004B7402 /* ZAShapeButton.xcdatamodeld */; }; 15 | 73ED65E51B43DD76004B7402 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 73ED65E41B43DD76004B7402 /* ViewController.m */; }; 16 | 73ED65E81B43DD76004B7402 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 73ED65E61B43DD76004B7402 /* Main.storyboard */; }; 17 | 73ED65EA1B43DD76004B7402 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 73ED65E91B43DD76004B7402 /* Images.xcassets */; }; 18 | 73ED65ED1B43DD76004B7402 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 73ED65EB1B43DD76004B7402 /* LaunchScreen.xib */; }; 19 | 73ED65F91B43DD76004B7402 /* ZAShapeButtonTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 73ED65F81B43DD76004B7402 /* ZAShapeButtonTests.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 73ED65F31B43DD76004B7402 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 73ED65CE1B43DD76004B7402 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 73ED65D51B43DD76004B7402; 28 | remoteInfo = ZAShapeButton; 29 | }; 30 | /* End PBXContainerItemProxy section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 7329B4231E5313E500F33901 /* button.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = button.xcassets; sourceTree = ""; }; 34 | 7329B4251E5313E500F33901 /* ZAShapeButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZAShapeButton.h; sourceTree = ""; }; 35 | 7329B4261E5313E500F33901 /* ZAShapeButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZAShapeButton.m; sourceTree = ""; }; 36 | 73ED65D61B43DD76004B7402 /* ZAShapeButton.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ZAShapeButton.app; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | 73ED65DA1B43DD76004B7402 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | 73ED65DB1B43DD76004B7402 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 39 | 73ED65DD1B43DD76004B7402 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 40 | 73ED65DE1B43DD76004B7402 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 41 | 73ED65E11B43DD76004B7402 /* ZAShapeButton.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = ZAShapeButton.xcdatamodel; sourceTree = ""; }; 42 | 73ED65E31B43DD76004B7402 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 43 | 73ED65E41B43DD76004B7402 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 44 | 73ED65E71B43DD76004B7402 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | 73ED65E91B43DD76004B7402 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 46 | 73ED65EC1B43DD76004B7402 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 47 | 73ED65F21B43DD76004B7402 /* ZAShapeButtonTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ZAShapeButtonTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | 73ED65F71B43DD76004B7402 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 73ED65F81B43DD76004B7402 /* ZAShapeButtonTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ZAShapeButtonTests.m; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 73ED65D31B43DD76004B7402 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | 73ED65EF1B43DD76004B7402 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXFrameworksBuildPhase section */ 68 | 69 | /* Begin PBXGroup section */ 70 | 7329B4211E5313E500F33901 /* ShapeButton */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 7329B4221E5313E500F33901 /* Assets */, 74 | 7329B4241E5313E500F33901 /* Classes */, 75 | ); 76 | path = ShapeButton; 77 | sourceTree = ""; 78 | }; 79 | 7329B4221E5313E500F33901 /* Assets */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 7329B4231E5313E500F33901 /* button.xcassets */, 83 | ); 84 | path = Assets; 85 | sourceTree = ""; 86 | }; 87 | 7329B4241E5313E500F33901 /* Classes */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 7329B4251E5313E500F33901 /* ZAShapeButton.h */, 91 | 7329B4261E5313E500F33901 /* ZAShapeButton.m */, 92 | ); 93 | path = Classes; 94 | sourceTree = ""; 95 | }; 96 | 73ED65CD1B43DD76004B7402 = { 97 | isa = PBXGroup; 98 | children = ( 99 | 73ED65D81B43DD76004B7402 /* ZAShapeButton */, 100 | 73ED65F51B43DD76004B7402 /* ZAShapeButtonTests */, 101 | 73ED65D71B43DD76004B7402 /* Products */, 102 | ); 103 | sourceTree = ""; 104 | }; 105 | 73ED65D71B43DD76004B7402 /* Products */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 73ED65D61B43DD76004B7402 /* ZAShapeButton.app */, 109 | 73ED65F21B43DD76004B7402 /* ZAShapeButtonTests.xctest */, 110 | ); 111 | name = Products; 112 | sourceTree = ""; 113 | }; 114 | 73ED65D81B43DD76004B7402 /* ZAShapeButton */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 7329B4211E5313E500F33901 /* ShapeButton */, 118 | 73ED65DD1B43DD76004B7402 /* AppDelegate.h */, 119 | 73ED65DE1B43DD76004B7402 /* AppDelegate.m */, 120 | 73ED65E31B43DD76004B7402 /* ViewController.h */, 121 | 73ED65E41B43DD76004B7402 /* ViewController.m */, 122 | 73ED65E61B43DD76004B7402 /* Main.storyboard */, 123 | 73ED65E91B43DD76004B7402 /* Images.xcassets */, 124 | 73ED65EB1B43DD76004B7402 /* LaunchScreen.xib */, 125 | 73ED65E01B43DD76004B7402 /* ZAShapeButton.xcdatamodeld */, 126 | 73ED65D91B43DD76004B7402 /* Supporting Files */, 127 | ); 128 | path = ZAShapeButton; 129 | sourceTree = ""; 130 | }; 131 | 73ED65D91B43DD76004B7402 /* Supporting Files */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | 73ED65DA1B43DD76004B7402 /* Info.plist */, 135 | 73ED65DB1B43DD76004B7402 /* main.m */, 136 | ); 137 | name = "Supporting Files"; 138 | sourceTree = ""; 139 | }; 140 | 73ED65F51B43DD76004B7402 /* ZAShapeButtonTests */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | 73ED65F81B43DD76004B7402 /* ZAShapeButtonTests.m */, 144 | 73ED65F61B43DD76004B7402 /* Supporting Files */, 145 | ); 146 | path = ZAShapeButtonTests; 147 | sourceTree = ""; 148 | }; 149 | 73ED65F61B43DD76004B7402 /* Supporting Files */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | 73ED65F71B43DD76004B7402 /* Info.plist */, 153 | ); 154 | name = "Supporting Files"; 155 | sourceTree = ""; 156 | }; 157 | /* End PBXGroup section */ 158 | 159 | /* Begin PBXNativeTarget section */ 160 | 73ED65D51B43DD76004B7402 /* ZAShapeButton */ = { 161 | isa = PBXNativeTarget; 162 | buildConfigurationList = 73ED65FC1B43DD76004B7402 /* Build configuration list for PBXNativeTarget "ZAShapeButton" */; 163 | buildPhases = ( 164 | 73ED65D21B43DD76004B7402 /* Sources */, 165 | 73ED65D31B43DD76004B7402 /* Frameworks */, 166 | 73ED65D41B43DD76004B7402 /* Resources */, 167 | ); 168 | buildRules = ( 169 | ); 170 | dependencies = ( 171 | ); 172 | name = ZAShapeButton; 173 | productName = ZAShapeButton; 174 | productReference = 73ED65D61B43DD76004B7402 /* ZAShapeButton.app */; 175 | productType = "com.apple.product-type.application"; 176 | }; 177 | 73ED65F11B43DD76004B7402 /* ZAShapeButtonTests */ = { 178 | isa = PBXNativeTarget; 179 | buildConfigurationList = 73ED65FF1B43DD76004B7402 /* Build configuration list for PBXNativeTarget "ZAShapeButtonTests" */; 180 | buildPhases = ( 181 | 73ED65EE1B43DD76004B7402 /* Sources */, 182 | 73ED65EF1B43DD76004B7402 /* Frameworks */, 183 | 73ED65F01B43DD76004B7402 /* Resources */, 184 | ); 185 | buildRules = ( 186 | ); 187 | dependencies = ( 188 | 73ED65F41B43DD76004B7402 /* PBXTargetDependency */, 189 | ); 190 | name = ZAShapeButtonTests; 191 | productName = ZAShapeButtonTests; 192 | productReference = 73ED65F21B43DD76004B7402 /* ZAShapeButtonTests.xctest */; 193 | productType = "com.apple.product-type.bundle.unit-test"; 194 | }; 195 | /* End PBXNativeTarget section */ 196 | 197 | /* Begin PBXProject section */ 198 | 73ED65CE1B43DD76004B7402 /* Project object */ = { 199 | isa = PBXProject; 200 | attributes = { 201 | LastUpgradeCheck = 0830; 202 | ORGANIZATIONNAME = zhuoapp; 203 | TargetAttributes = { 204 | 73ED65D51B43DD76004B7402 = { 205 | CreatedOnToolsVersion = 6.3; 206 | }; 207 | 73ED65F11B43DD76004B7402 = { 208 | CreatedOnToolsVersion = 6.3; 209 | TestTargetID = 73ED65D51B43DD76004B7402; 210 | }; 211 | }; 212 | }; 213 | buildConfigurationList = 73ED65D11B43DD76004B7402 /* Build configuration list for PBXProject "ZAShapeButton" */; 214 | compatibilityVersion = "Xcode 3.2"; 215 | developmentRegion = English; 216 | hasScannedForEncodings = 0; 217 | knownRegions = ( 218 | en, 219 | Base, 220 | ); 221 | mainGroup = 73ED65CD1B43DD76004B7402; 222 | productRefGroup = 73ED65D71B43DD76004B7402 /* Products */; 223 | projectDirPath = ""; 224 | projectRoot = ""; 225 | targets = ( 226 | 73ED65D51B43DD76004B7402 /* ZAShapeButton */, 227 | 73ED65F11B43DD76004B7402 /* ZAShapeButtonTests */, 228 | ); 229 | }; 230 | /* End PBXProject section */ 231 | 232 | /* Begin PBXResourcesBuildPhase section */ 233 | 73ED65D41B43DD76004B7402 /* Resources */ = { 234 | isa = PBXResourcesBuildPhase; 235 | buildActionMask = 2147483647; 236 | files = ( 237 | 73ED65E81B43DD76004B7402 /* Main.storyboard in Resources */, 238 | 73ED65ED1B43DD76004B7402 /* LaunchScreen.xib in Resources */, 239 | 73ED65EA1B43DD76004B7402 /* Images.xcassets in Resources */, 240 | 7329B4271E5313E500F33901 /* button.xcassets in Resources */, 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | 73ED65F01B43DD76004B7402 /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | /* End PBXResourcesBuildPhase section */ 252 | 253 | /* Begin PBXSourcesBuildPhase section */ 254 | 73ED65D21B43DD76004B7402 /* Sources */ = { 255 | isa = PBXSourcesBuildPhase; 256 | buildActionMask = 2147483647; 257 | files = ( 258 | 73ED65E21B43DD76004B7402 /* ZAShapeButton.xcdatamodeld in Sources */, 259 | 73ED65DF1B43DD76004B7402 /* AppDelegate.m in Sources */, 260 | 7329B4281E5313E500F33901 /* ZAShapeButton.m in Sources */, 261 | 73ED65E51B43DD76004B7402 /* ViewController.m in Sources */, 262 | 73ED65DC1B43DD76004B7402 /* main.m in Sources */, 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | }; 266 | 73ED65EE1B43DD76004B7402 /* Sources */ = { 267 | isa = PBXSourcesBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | 73ED65F91B43DD76004B7402 /* ZAShapeButtonTests.m in Sources */, 271 | ); 272 | runOnlyForDeploymentPostprocessing = 0; 273 | }; 274 | /* End PBXSourcesBuildPhase section */ 275 | 276 | /* Begin PBXTargetDependency section */ 277 | 73ED65F41B43DD76004B7402 /* PBXTargetDependency */ = { 278 | isa = PBXTargetDependency; 279 | target = 73ED65D51B43DD76004B7402 /* ZAShapeButton */; 280 | targetProxy = 73ED65F31B43DD76004B7402 /* PBXContainerItemProxy */; 281 | }; 282 | /* End PBXTargetDependency section */ 283 | 284 | /* Begin PBXVariantGroup section */ 285 | 73ED65E61B43DD76004B7402 /* Main.storyboard */ = { 286 | isa = PBXVariantGroup; 287 | children = ( 288 | 73ED65E71B43DD76004B7402 /* Base */, 289 | ); 290 | name = Main.storyboard; 291 | sourceTree = ""; 292 | }; 293 | 73ED65EB1B43DD76004B7402 /* LaunchScreen.xib */ = { 294 | isa = PBXVariantGroup; 295 | children = ( 296 | 73ED65EC1B43DD76004B7402 /* Base */, 297 | ); 298 | name = LaunchScreen.xib; 299 | sourceTree = ""; 300 | }; 301 | /* End PBXVariantGroup section */ 302 | 303 | /* Begin XCBuildConfiguration section */ 304 | 73ED65FA1B43DD76004B7402 /* Debug */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | ALWAYS_SEARCH_USER_PATHS = NO; 308 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 309 | CLANG_CXX_LIBRARY = "libc++"; 310 | CLANG_ENABLE_MODULES = YES; 311 | CLANG_ENABLE_OBJC_ARC = YES; 312 | CLANG_WARN_BOOL_CONVERSION = YES; 313 | CLANG_WARN_CONSTANT_CONVERSION = YES; 314 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 315 | CLANG_WARN_EMPTY_BODY = YES; 316 | CLANG_WARN_ENUM_CONVERSION = YES; 317 | CLANG_WARN_INFINITE_RECURSION = YES; 318 | CLANG_WARN_INT_CONVERSION = YES; 319 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 320 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 321 | CLANG_WARN_UNREACHABLE_CODE = YES; 322 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 323 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 324 | COPY_PHASE_STRIP = NO; 325 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 326 | ENABLE_STRICT_OBJC_MSGSEND = YES; 327 | ENABLE_TESTABILITY = YES; 328 | GCC_C_LANGUAGE_STANDARD = gnu99; 329 | GCC_DYNAMIC_NO_PIC = NO; 330 | GCC_NO_COMMON_BLOCKS = YES; 331 | GCC_OPTIMIZATION_LEVEL = 0; 332 | GCC_PREPROCESSOR_DEFINITIONS = ( 333 | "DEBUG=1", 334 | "$(inherited)", 335 | ); 336 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 337 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 338 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 339 | GCC_WARN_UNDECLARED_SELECTOR = YES; 340 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 341 | GCC_WARN_UNUSED_FUNCTION = YES; 342 | GCC_WARN_UNUSED_VARIABLE = YES; 343 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 344 | MTL_ENABLE_DEBUG_INFO = YES; 345 | ONLY_ACTIVE_ARCH = YES; 346 | SDKROOT = iphoneos; 347 | TARGETED_DEVICE_FAMILY = "1,2"; 348 | }; 349 | name = Debug; 350 | }; 351 | 73ED65FB1B43DD76004B7402 /* Release */ = { 352 | isa = XCBuildConfiguration; 353 | buildSettings = { 354 | ALWAYS_SEARCH_USER_PATHS = NO; 355 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 356 | CLANG_CXX_LIBRARY = "libc++"; 357 | CLANG_ENABLE_MODULES = YES; 358 | CLANG_ENABLE_OBJC_ARC = YES; 359 | CLANG_WARN_BOOL_CONVERSION = YES; 360 | CLANG_WARN_CONSTANT_CONVERSION = YES; 361 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 362 | CLANG_WARN_EMPTY_BODY = YES; 363 | CLANG_WARN_ENUM_CONVERSION = YES; 364 | CLANG_WARN_INFINITE_RECURSION = YES; 365 | CLANG_WARN_INT_CONVERSION = YES; 366 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 367 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 368 | CLANG_WARN_UNREACHABLE_CODE = YES; 369 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 370 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 371 | COPY_PHASE_STRIP = NO; 372 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 373 | ENABLE_NS_ASSERTIONS = NO; 374 | ENABLE_STRICT_OBJC_MSGSEND = YES; 375 | GCC_C_LANGUAGE_STANDARD = gnu99; 376 | GCC_NO_COMMON_BLOCKS = YES; 377 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 378 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 379 | GCC_WARN_UNDECLARED_SELECTOR = YES; 380 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 381 | GCC_WARN_UNUSED_FUNCTION = YES; 382 | GCC_WARN_UNUSED_VARIABLE = YES; 383 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 384 | MTL_ENABLE_DEBUG_INFO = NO; 385 | SDKROOT = iphoneos; 386 | TARGETED_DEVICE_FAMILY = "1,2"; 387 | VALIDATE_PRODUCT = YES; 388 | }; 389 | name = Release; 390 | }; 391 | 73ED65FD1B43DD76004B7402 /* Debug */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 395 | INFOPLIST_FILE = ZAShapeButton/Info.plist; 396 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 397 | PRODUCT_BUNDLE_IDENTIFIER = "ZA.$(PRODUCT_NAME:rfc1034identifier)"; 398 | PRODUCT_NAME = "$(TARGET_NAME)"; 399 | }; 400 | name = Debug; 401 | }; 402 | 73ED65FE1B43DD76004B7402 /* Release */ = { 403 | isa = XCBuildConfiguration; 404 | buildSettings = { 405 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 406 | INFOPLIST_FILE = ZAShapeButton/Info.plist; 407 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 408 | PRODUCT_BUNDLE_IDENTIFIER = "ZA.$(PRODUCT_NAME:rfc1034identifier)"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | }; 411 | name = Release; 412 | }; 413 | 73ED66001B43DD76004B7402 /* Debug */ = { 414 | isa = XCBuildConfiguration; 415 | buildSettings = { 416 | BUNDLE_LOADER = "$(TEST_HOST)"; 417 | FRAMEWORK_SEARCH_PATHS = ( 418 | "$(SDKROOT)/Developer/Library/Frameworks", 419 | "$(inherited)", 420 | ); 421 | GCC_PREPROCESSOR_DEFINITIONS = ( 422 | "DEBUG=1", 423 | "$(inherited)", 424 | ); 425 | INFOPLIST_FILE = ZAShapeButtonTests/Info.plist; 426 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 427 | PRODUCT_BUNDLE_IDENTIFIER = "ZA.$(PRODUCT_NAME:rfc1034identifier)"; 428 | PRODUCT_NAME = "$(TARGET_NAME)"; 429 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ZAShapeButton.app/ZAShapeButton"; 430 | }; 431 | name = Debug; 432 | }; 433 | 73ED66011B43DD76004B7402 /* Release */ = { 434 | isa = XCBuildConfiguration; 435 | buildSettings = { 436 | BUNDLE_LOADER = "$(TEST_HOST)"; 437 | FRAMEWORK_SEARCH_PATHS = ( 438 | "$(SDKROOT)/Developer/Library/Frameworks", 439 | "$(inherited)", 440 | ); 441 | INFOPLIST_FILE = ZAShapeButtonTests/Info.plist; 442 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 443 | PRODUCT_BUNDLE_IDENTIFIER = "ZA.$(PRODUCT_NAME:rfc1034identifier)"; 444 | PRODUCT_NAME = "$(TARGET_NAME)"; 445 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ZAShapeButton.app/ZAShapeButton"; 446 | }; 447 | name = Release; 448 | }; 449 | /* End XCBuildConfiguration section */ 450 | 451 | /* Begin XCConfigurationList section */ 452 | 73ED65D11B43DD76004B7402 /* Build configuration list for PBXProject "ZAShapeButton" */ = { 453 | isa = XCConfigurationList; 454 | buildConfigurations = ( 455 | 73ED65FA1B43DD76004B7402 /* Debug */, 456 | 73ED65FB1B43DD76004B7402 /* Release */, 457 | ); 458 | defaultConfigurationIsVisible = 0; 459 | defaultConfigurationName = Release; 460 | }; 461 | 73ED65FC1B43DD76004B7402 /* Build configuration list for PBXNativeTarget "ZAShapeButton" */ = { 462 | isa = XCConfigurationList; 463 | buildConfigurations = ( 464 | 73ED65FD1B43DD76004B7402 /* Debug */, 465 | 73ED65FE1B43DD76004B7402 /* Release */, 466 | ); 467 | defaultConfigurationIsVisible = 0; 468 | defaultConfigurationName = Release; 469 | }; 470 | 73ED65FF1B43DD76004B7402 /* Build configuration list for PBXNativeTarget "ZAShapeButtonTests" */ = { 471 | isa = XCConfigurationList; 472 | buildConfigurations = ( 473 | 73ED66001B43DD76004B7402 /* Debug */, 474 | 73ED66011B43DD76004B7402 /* Release */, 475 | ); 476 | defaultConfigurationIsVisible = 0; 477 | defaultConfigurationName = Release; 478 | }; 479 | /* End XCConfigurationList section */ 480 | 481 | /* Begin XCVersionGroup section */ 482 | 73ED65E01B43DD76004B7402 /* ZAShapeButton.xcdatamodeld */ = { 483 | isa = XCVersionGroup; 484 | children = ( 485 | 73ED65E11B43DD76004B7402 /* ZAShapeButton.xcdatamodel */, 486 | ); 487 | currentVersion = 73ED65E11B43DD76004B7402 /* ZAShapeButton.xcdatamodel */; 488 | path = ZAShapeButton.xcdatamodeld; 489 | sourceTree = ""; 490 | versionGroupType = wrapper.xcdatamodel; 491 | }; 492 | /* End XCVersionGroup section */ 493 | }; 494 | rootObject = 73ED65CE1B43DD76004B7402 /* Project object */; 495 | } 496 | -------------------------------------------------------------------------------- /ZAShapeButton.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ZAShapeButton.xcodeproj/project.xcworkspace/xcshareddata/ZAShapeButton.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 0D537AA7-72F4-472B-B53C-7B09C5D99186 9 | IDESourceControlProjectName 10 | ZAShapeButton 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | DEFDE0057750B6E4F114E9A353BDC71E671D66A9 14 | https://github.com/chuting/ZAShapButton.git 15 | 16 | IDESourceControlProjectPath 17 | ZAShapeButton.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | DEFDE0057750B6E4F114E9A353BDC71E671D66A9 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/chuting/ZAShapButton.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | DEFDE0057750B6E4F114E9A353BDC71E671D66A9 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | DEFDE0057750B6E4F114E9A353BDC71E671D66A9 36 | IDESourceControlWCCName 37 | ZAShapButton 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ZAShapeButton.xcodeproj/project.xcworkspace/xcuserdata/zhuoapp.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton.xcodeproj/project.xcworkspace/xcuserdata/zhuoapp.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ZAShapeButton.xcodeproj/project.xcworkspace/xcuserdata/zhutc.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton.xcodeproj/project.xcworkspace/xcuserdata/zhutc.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ZAShapeButton.xcodeproj/xcuserdata/zhuoapp.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 40 | 52 | 53 | 54 | 56 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /ZAShapeButton.xcodeproj/xcuserdata/zhuoapp.xcuserdatad/xcschemes/ZAShapeButton.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /ZAShapeButton.xcodeproj/xcuserdata/zhuoapp.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ZAShapeButton.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 73ED65D51B43DD76004B7402 16 | 17 | primary 18 | 19 | 20 | 73ED65F11B43DD76004B7402 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ZAShapeButton.xcodeproj/xcuserdata/zhutc.xcuserdatad/xcschemes/ZAShapeButton.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /ZAShapeButton.xcodeproj/xcuserdata/zhutc.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ZAShapeButton.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 73ED65D51B43DD76004B7402 16 | 17 | primary 18 | 19 | 20 | 73ED65F11B43DD76004B7402 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ZAShapeButton/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/.DS_Store -------------------------------------------------------------------------------- /ZAShapeButton/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ZAShapeButton 4 | // 5 | // Created by zhuoapp on 15/7/1. 6 | // Copyright (c) 2015年 zhuoapp. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (strong, nonatomic) UIWindow *window; 15 | 16 | @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; 17 | @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; 18 | @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; 19 | 20 | - (void)saveContext; 21 | - (NSURL *)applicationDocumentsDirectory; 22 | 23 | 24 | @end 25 | 26 | -------------------------------------------------------------------------------- /ZAShapeButton/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ZAShapeButton 4 | // 5 | // Created by zhuoapp on 15/7/1. 6 | // Copyright (c) 2015年 zhuoapp. 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 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | // Saves changes in the application's managed object context before the application terminates. 44 | [self saveContext]; 45 | } 46 | 47 | #pragma mark - Core Data stack 48 | 49 | @synthesize managedObjectContext = _managedObjectContext; 50 | @synthesize managedObjectModel = _managedObjectModel; 51 | @synthesize persistentStoreCoordinator = _persistentStoreCoordinator; 52 | 53 | - (NSURL *)applicationDocumentsDirectory { 54 | // The directory the application uses to store the Core Data store file. This code uses a directory named "ZA.ZAShapeButton" in the application's documents directory. 55 | return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; 56 | } 57 | 58 | - (NSManagedObjectModel *)managedObjectModel { 59 | // The managed object model for the application. It is a fatal error for the application not to be able to find and load its model. 60 | if (_managedObjectModel != nil) { 61 | return _managedObjectModel; 62 | } 63 | NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"ZAShapeButton" withExtension:@"momd"]; 64 | _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; 65 | return _managedObjectModel; 66 | } 67 | 68 | - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { 69 | // The persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. 70 | if (_persistentStoreCoordinator != nil) { 71 | return _persistentStoreCoordinator; 72 | } 73 | 74 | // Create the coordinator and store 75 | 76 | _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; 77 | NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"ZAShapeButton.sqlite"]; 78 | NSError *error = nil; 79 | NSString *failureReason = @"There was an error creating or loading the application's saved data."; 80 | if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) { 81 | // Report any error we got. 82 | NSMutableDictionary *dict = [NSMutableDictionary dictionary]; 83 | dict[NSLocalizedDescriptionKey] = @"Failed to initialize the application's saved data"; 84 | dict[NSLocalizedFailureReasonErrorKey] = failureReason; 85 | dict[NSUnderlyingErrorKey] = error; 86 | error = [NSError errorWithDomain:@"YOUR_ERROR_DOMAIN" code:9999 userInfo:dict]; 87 | // Replace this with code to handle the error appropriately. 88 | // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 89 | NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 90 | abort(); 91 | } 92 | 93 | return _persistentStoreCoordinator; 94 | } 95 | 96 | 97 | - (NSManagedObjectContext *)managedObjectContext { 98 | // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) 99 | if (_managedObjectContext != nil) { 100 | return _managedObjectContext; 101 | } 102 | 103 | NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; 104 | if (!coordinator) { 105 | return nil; 106 | } 107 | _managedObjectContext = [[NSManagedObjectContext alloc] init]; 108 | [_managedObjectContext setPersistentStoreCoordinator:coordinator]; 109 | return _managedObjectContext; 110 | } 111 | 112 | #pragma mark - Core Data Saving support 113 | 114 | - (void)saveContext { 115 | NSManagedObjectContext *managedObjectContext = self.managedObjectContext; 116 | if (managedObjectContext != nil) { 117 | NSError *error = nil; 118 | if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) { 119 | // Replace this implementation with code to handle the error appropriately. 120 | // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 121 | NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 122 | abort(); 123 | } 124 | } 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /ZAShapeButton/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ZAShapeButton/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 | 26 | -------------------------------------------------------------------------------- /ZAShapeButton/Images.xcassets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/Images.xcassets/.DS_Store -------------------------------------------------------------------------------- /ZAShapeButton/Images.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 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /ZAShapeButton/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ZAShapeButton/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/.DS_Store -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/.DS_Store -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_h.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tv_voice@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "tv_voice@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_h.imageset/tv_voice@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_h.imageset/tv_voice@2x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_h.imageset/tv_voice@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_h.imageset/tv_voice@3x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_number.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tv_numberbtn@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "tv_numberbtn@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_number.imageset/tv_numberbtn@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_number.imageset/tv_numberbtn@2x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_number.imageset/tv_numberbtn@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_number.imageset/tv_numberbtn@3x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_rect.imageset/2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_rect.imageset/2@2x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_rect.imageset/2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_rect.imageset/2@3x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_rect.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "2@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "2@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_round.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "custom_annulus2@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "custom_annulus2.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_round.imageset/custom_annulus2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_round.imageset/custom_annulus2.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_round.imageset/custom_annulus2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_round.imageset/custom_annulus2@2x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_round_single.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "circle@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "circle@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_round_single.imageset/circle@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_round_single.imageset/circle@2x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_round_single.imageset/circle@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_round_single.imageset/circle@3x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_setting.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "setting@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "setting@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_setting.imageset/setting@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_setting.imageset/setting@2x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_setting.imageset/setting@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_setting.imageset/setting@3x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_switch.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "open@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "open@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_switch.imageset/open@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_switch.imageset/open@2x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_switch.imageset/open@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_switch.imageset/open@3x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_v.imageset/1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_v.imageset/1@2x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_v.imageset/1@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chuting/ZAShapButton/23102e8a9c5ea39b9a031c79144b4437c9036845/ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_v.imageset/1@3x.png -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Assets/button.xcassets/virtual_control_v.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "1@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "1@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Classes/ZAShapeButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZAShapeButton.h 3 | // OppleOnline 4 | // 5 | // Created by zhuoapp on 15/6/3. 6 | // Copyright (c) 2015年 zhuoapp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | typedef enum ButtonType{ 14 | 15 | /** 16 | * 圆形五个按钮 上下左右 中心 17 | */ 18 | ButtonTypeRound=0, 19 | /** 20 | * 单个圆形按钮 只响应 SelectButtonPosition_Center 21 | */ 22 | ButtonTypeRoundSingle, 23 | /** 24 | * 圆角按钮 只响应 SelectButtonPosition_Center 25 | */ 26 | ButtonTypeRect, 27 | /** 28 | * 竖加减 只响应 SelectButtonPosition_Buttom SelectButtonPosition_Top, 29 | */ 30 | ButtonTypeVPlusAndMin, 31 | 32 | /** 33 | * 横加减 只响应 SelectButtonPosition_Right SelectButtonPosition_Left, 34 | */ 35 | ButtonTypeHPlusAndMin, 36 | 37 | }ButtonType; 38 | 39 | 40 | 41 | 42 | typedef enum ButtonClickType 43 | { 44 | 45 | //手势抬起响应 46 | ButtonClickTypeTouchUpInside=0, 47 | 48 | //长按0.5s响应 49 | ButtonClickTypeLongPress, 50 | 51 | 52 | }ButtonClickType; 53 | 54 | 55 | 56 | typedef enum SelectButtonPosition{ 57 | 58 | SelectButtonPositionTop =1, 59 | SelectButtonPositionRight =1<<1 , 60 | SelectButtonPositionButtom =1<<2 , 61 | SelectButtonPositionLeft =1<<3, 62 | SelectButtonPositionCenter =1<<4, 63 | 64 | }SelectButtonPosition; 65 | 66 | @interface ZAShapeButton : UIImageView 67 | { 68 | 69 | 70 | // NSArray *pathArray; 71 | NSMutableArray *layerArray; 72 | SEL touchAction; 73 | SEL longPressAction; 74 | id handel; 75 | 76 | UIGestureRecognizerState responseState; 77 | 78 | 79 | ButtonType buttonType; 80 | 81 | UILabel *titleLabel; 82 | 83 | 84 | NSTimer *longPressTimer; 85 | 86 | 87 | UILongPressGestureRecognizer *longPressGestureRecognizer; 88 | 89 | 90 | //长按手势未执行 91 | BOOL longPressNotComplete ; 92 | } 93 | 94 | /** 95 | * 获取选中位置 96 | */ 97 | @property (nonatomic) enum SelectButtonPosition selectButtonPosition; 98 | 99 | 100 | /** 101 | * 初始化button 102 | * 103 | * @param frame <#frame description#> 104 | * @param type button 类型 105 | * 106 | * @return <#return value description#> 107 | */ 108 | -(instancetype)initWithFrame:(CGRect)frame ButtonType:(ButtonType)type; 109 | 110 | 111 | -(void)addTarget:(id)target action:(SEL)action forResponseState:(ButtonClickType)state; 112 | 113 | 114 | /** 115 | * 设置响应位置, 116 | * 117 | * @param position 可以传多个参数 118 | */ 119 | -(void)setResponsePosition:(SelectButtonPosition)position; 120 | 121 | 122 | -(void)setTitle:(NSString *)title; 123 | 124 | @end 125 | -------------------------------------------------------------------------------- /ZAShapeButton/ShapeButton/Classes/ZAShapeButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZAShapeButton.m 3 | // OppleOnline 4 | // 5 | // Created by zhuoapp on 15/6/3. 6 | // Copyright (c) 2015年 zhuoapp. All rights reserved. 7 | // 8 | 9 | #import "ZAShapeButton.h" 10 | 11 | 12 | #define PathKey @"path" 13 | #define PositionKey @"position" 14 | #define PathDic(path,position) [NSDictionary dictionaryWithObjectsAndKeys:path,@"path",position,@"position", nil] 15 | #define OffSet 2.5 16 | @interface ZAShapeButton() 17 | 18 | @property (nonatomic) NSMutableArray *pathArray; 19 | @end 20 | 21 | @implementation ZAShapeButton 22 | @synthesize selectButtonPosition; 23 | /* 24 | // Only override drawRect: if you perform custom drawing. 25 | // An empty implementation adversely affects performance during animation. 26 | - (void)drawRect:(CGRect)rect { 27 | // Drawing code 28 | } 29 | */ 30 | 31 | 32 | 33 | -(instancetype)initWithFrame:(CGRect)frame ButtonType:(ButtonType)type 34 | { 35 | self=[super initWithFrame:frame]; 36 | if (!self) { 37 | return nil; 38 | } 39 | buttonType=type; 40 | titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0,CGRectGetWidth(frame), CGRectGetHeight(frame))]; 41 | titleLabel.backgroundColor=[UIColor clearColor]; 42 | titleLabel.textColor=[UIColor colorWithRed:159/255.0 green:159/255.0 blue:167/255.0 alpha:1]; 43 | titleLabel.font=[UIFont systemFontOfSize:15]; 44 | titleLabel.textAlignment=NSTextAlignmentCenter; 45 | [self addSubview:titleLabel]; 46 | 47 | self.userInteractionEnabled=YES; 48 | 49 | longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressGesture:)]; 50 | longPressGestureRecognizer.minimumPressDuration=0.05; 51 | [self addGestureRecognizer:longPressGestureRecognizer]; 52 | 53 | switch (type) { 54 | case ButtonTypeRect: 55 | self.image=[UIImage imageNamed:@"virtual_control_rect"] ; 56 | break; 57 | case ButtonTypeRoundSingle: 58 | self.image=[UIImage imageNamed:@"virtual_control_round_single"]; 59 | break; 60 | case ButtonTypeRound: 61 | self.image=[UIImage imageNamed:@"virtual_control_round"]; 62 | break; 63 | case ButtonTypeHPlusAndMin: 64 | self.image=[UIImage imageNamed:@"virtual_control_h"] ; 65 | break; 66 | case ButtonTypeVPlusAndMin: 67 | self.image=[UIImage imageNamed:@"virtual_control_v"]; 68 | break; 69 | default: 70 | break; 71 | } 72 | return self; 73 | } 74 | 75 | 76 | 77 | -(void)setImage:(UIImage *)image 78 | { 79 | [super setImage:image]; 80 | self.frame=CGRectMake(CGRectGetMinX(self.frame), CGRectGetMinY(self.frame), self.image.size.width, self.image.size.height); 81 | titleLabel.frame=CGRectMake(0, 0,CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)); 82 | 83 | } 84 | #pragma mark - 设置标题 85 | -(void)setTitle:(NSString *)title 86 | { 87 | titleLabel.text=title; 88 | } 89 | 90 | 91 | #pragma mark - 设置响应位置 92 | -(void)setResponsePosition:(SelectButtonPosition)position 93 | { 94 | if (!_pathArray) { 95 | _pathArray=[[NSMutableArray alloc]init]; 96 | }else{ 97 | [_pathArray removeAllObjects]; 98 | } 99 | 100 | if (buttonType==ButtonTypeHPlusAndMin) { 101 | if (position & SelectButtonPositionLeft) { 102 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPositionLeft]]; 103 | } 104 | 105 | if (position & SelectButtonPositionRight) { 106 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPositionRight]]; 107 | } 108 | } 109 | 110 | if (buttonType==ButtonTypeVPlusAndMin) { 111 | if (position & SelectButtonPositionTop) { 112 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPositionTop]]; 113 | } 114 | if (position & SelectButtonPositionButtom) { 115 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPositionButtom]]; 116 | } 117 | } 118 | 119 | if (buttonType==ButtonTypeRound) { 120 | if (position & SelectButtonPositionTop) { 121 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPositionTop]]; 122 | } 123 | if (position & SelectButtonPositionLeft) { 124 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPositionLeft]]; 125 | } 126 | if (position & SelectButtonPositionRight) { 127 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPositionRight]]; 128 | } 129 | if (position & SelectButtonPositionButtom) { 130 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPositionButtom]]; 131 | } 132 | if (position & SelectButtonPositionCenter) { 133 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPositionCenter]]; 134 | } 135 | } 136 | } 137 | 138 | #pragma mark - 获取路径数组 139 | -(NSMutableArray *)pathArray 140 | { 141 | if (!_pathArray) { 142 | _pathArray=[[NSMutableArray alloc]init]; 143 | switch (buttonType) { 144 | case ButtonTypeHPlusAndMin: 145 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPositionLeft]]; 146 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPositionRight]]; 147 | break; 148 | case ButtonTypeVPlusAndMin: 149 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPositionTop]]; 150 | [_pathArray addObject:[self rectShapWithPosition:SelectButtonPositionButtom]]; 151 | break; 152 | case ButtonTypeRound: 153 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPositionLeft]]; 154 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPositionRight]]; 155 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPositionTop]]; 156 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPositionButtom]]; 157 | [_pathArray addObject:[self roundShapWithPosition:SelectButtonPositionCenter]]; 158 | break; 159 | case ButtonTypeRoundSingle: 160 | [_pathArray addObject:[self roundShap]]; 161 | break; 162 | case ButtonTypeRect: 163 | [_pathArray addObject:[self rectShap]]; 164 | break; 165 | default: 166 | break; 167 | } 168 | 169 | } 170 | return _pathArray; 171 | 172 | } 173 | 174 | 175 | 176 | #pragma mark - 添加响应事件 177 | -(void)addTarget:(id)target action:(SEL)action forResponseState:(ButtonClickType)state 178 | { 179 | handel=target; 180 | switch (state) { 181 | case ButtonClickTypeLongPress: 182 | longPressAction=action; 183 | break; 184 | case ButtonClickTypeTouchUpInside: 185 | touchAction=action; 186 | break; 187 | default: 188 | break; 189 | } 190 | } 191 | 192 | 193 | 194 | #pragma mark - 触摸事件执行 195 | - (void)longPressGesture:(UILongPressGestureRecognizer*)longGesture{ 196 | 197 | BOOL containsPoint=[self containsPoint:[longPressGestureRecognizer locationInView:self]]; 198 | NSInteger tag = [self indexOfPoint:[longPressGestureRecognizer locationInView:self]]; 199 | 200 | if (containsPoint) { 201 | if (!layerArray) { 202 | layerArray=[[NSMutableArray alloc]init]; 203 | for (NSDictionary *dic in self.pathArray) { 204 | UIBezierPath *path=[dic objectForKey:PathKey]; 205 | CAShapeLayer *maskLayer = [CAShapeLayer layer]; 206 | maskLayer.path = [path CGPath]; 207 | maskLayer.fillColor = [[UIColor colorWithWhite:0 alpha:0.2] CGColor]; 208 | maskLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)); 209 | [self.layer addSublayer:maskLayer]; 210 | [layerArray addObject:maskLayer]; 211 | } 212 | } 213 | } 214 | 215 | if (longGesture &&(longGesture.state==UIGestureRecognizerStateBegan||longGesture.state==UIGestureRecognizerStateChanged)) { 216 | if (!containsPoint){ 217 | return; 218 | } 219 | if (longGesture.state==UIGestureRecognizerStateBegan) { 220 | longPressNotComplete=YES; 221 | if (longPressAction!=nil) { 222 | //如果有长按执行事件,则初始化timer 223 | longPressTimer=[NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(longPressTimerOut) userInfo:nil repeats:NO]; 224 | } 225 | } 226 | 227 | [UIView animateWithDuration:0.2 animations:^{ 228 | for (NSInteger i=0; i2*M_PI?(startAngle-2.0*M_PI):startAngle; 377 | float endAngle=startAngle+1/2.0*M_PI; 378 | [bezierPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; 379 | CGPoint point; 380 | point.x=center.x+radius*sin(endAngle); 381 | point.y=center.x+radius*cos(endAngle); 382 | [bezierPath addLineToPoint:point]; 383 | [bezierPath addArcWithCenter:center radius:radius-width startAngle:endAngle endAngle:startAngle clockwise:NO]; 384 | 385 | point.x=center.x+radius*sin(startAngle); 386 | point.y=center.y+radius*cos(startAngle); 387 | 388 | [bezierPath addLineToPoint:point]; 389 | [bezierPath closePath]; 390 | 391 | return PathDic(bezierPath, [NSNumber numberWithInteger:position]); 392 | } 393 | 394 | 395 | 396 | #pragma mark - 整圆贝塞尔曲线 397 | -(NSDictionary *)roundShap{ 398 | 399 | return [self roundPathWithRadius:(CGRectGetWidth(self.frame)/2.0-OffSet) center:CGPointMake(CGRectGetWidth(self.frame)/2, CGRectGetHeight(self.frame)/2)]; 400 | 401 | } 402 | 403 | 404 | 405 | #pragma mark - 406 | -(NSDictionary *)roundPathWithRadius:(float)radius center:(CGPoint)center 407 | { 408 | UIBezierPath* bezierPath = [UIBezierPath bezierPath]; 409 | [bezierPath addArcWithCenter:center radius:radius startAngle:0 endAngle:2.0*M_PI clockwise:YES]; 410 | [bezierPath closePath]; 411 | 412 | return PathDic(bezierPath, [NSNumber numberWithInteger:SelectButtonPositionCenter]); 413 | } 414 | 415 | 416 | 417 | #pragma mark - 整圆贝塞尔曲线 418 | -(NSDictionary *)rectShap{ 419 | UIBezierPath* bezierPath = [UIBezierPath bezierPath]; 420 | 421 | float offset=OffSet; 422 | 423 | float radius= CGRectGetHeight(self.frame)/2-offset; 424 | float width=CGRectGetWidth(self.frame)-2*radius-offset*2; 425 | CGRect frame=self.frame; 426 | CGPoint center; 427 | float startAngle ; 428 | float endAngle; 429 | center.x= radius+offset; 430 | center.y=CGRectGetHeight(frame)/2.0; 431 | startAngle=M_PI/2.0; 432 | endAngle=3/2.0*M_PI; 433 | [bezierPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; 434 | 435 | CGPoint point; 436 | 437 | point.x=center.x+width; 438 | point.y=offset; 439 | [bezierPath addLineToPoint:point]; 440 | 441 | 442 | center.x=point.x; 443 | [bezierPath addArcWithCenter:center radius:radius startAngle:endAngle endAngle:startAngle clockwise:YES]; 444 | [bezierPath closePath]; 445 | 446 | return PathDic(bezierPath, [NSNumber numberWithInteger:SelectButtonPositionCenter]); 447 | } 448 | 449 | 450 | 451 | #pragma mark - 获取获取点在数组的位置 452 | -(NSInteger)indexOfPoint:(CGPoint)point 453 | { 454 | for (NSDictionary *path in self.pathArray) { 455 | if ([[path objectForKey:PathKey] containsPoint:point]) { 456 | return [self.pathArray indexOfObject:path]; 457 | break; 458 | } 459 | } 460 | return -1; 461 | } 462 | 463 | 464 | 465 | 466 | #pragma mark - 获取位置 467 | -(SelectButtonPosition)GetPositonWithTag:(NSInteger)tag 468 | { 469 | NSDictionary *path=[self.pathArray objectAtIndex:tag]; 470 | return [[path objectForKey:PositionKey] intValue]; 471 | 472 | } 473 | 474 | 475 | #pragma mark - 点是否在曲线内 476 | -(BOOL)containsPoint:(CGPoint)point 477 | { 478 | return ([self indexOfPoint:point]==-1?NO:YES); 479 | 480 | } 481 | 482 | 483 | 484 | @end 485 | -------------------------------------------------------------------------------- /ZAShapeButton/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ZAShapeButton 4 | // 5 | // Created by zhuoapp on 15/7/1. 6 | // Copyright (c) 2015年 zhuoapp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ZAShapeButton/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ZAShapeButton 4 | // 5 | // Created by zhuoapp on 15/7/1. 6 | // Copyright (c) 2015年 zhuoapp. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "ZAShapeButton.h" 11 | 12 | @interface ViewController () 13 | { 14 | 15 | 16 | UILabel *showLabel; 17 | } 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view, typically from a nib. 25 | 26 | 27 | 28 | showLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 20,CGRectGetWidth(self.view.frame), 30)]; 29 | showLabel.backgroundColor=[UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1]; 30 | showLabel.textColor=[UIColor grayColor]; 31 | showLabel.textAlignment=NSTextAlignmentCenter; 32 | showLabel.text=@"暂无点击事件"; 33 | [self.view addSubview:showLabel]; 34 | 35 | 36 | 37 | NSArray *titleArray=@[@"OK",@"",@"",@"音量",@"音量"]; 38 | 39 | 40 | float height=CGRectGetMaxY(showLabel.frame)+20; 41 | for (int i=0; i<5; i++) { 42 | 43 | 44 | 45 | //1-5分别为 圆形五个按钮,单个圆形按钮,圆角按钮,竖加减,横加减 46 | 47 | 48 | 49 | 50 | ZAShapeButton *buttonView=[[ZAShapeButton alloc]initWithFrame:CGRectMake(0, 0, 50, 50) ButtonType:i]; 51 | [buttonView addTarget:self action:@selector(buttonClick:) forResponseState:ButtonClickTypeTouchUpInside]; 52 | [buttonView addTarget:self action:@selector(longPressButtonClick:) forResponseState:ButtonClickTypeLongPress]; 53 | [self.view addSubview:buttonView]; 54 | 55 | 56 | 57 | 58 | 59 | 60 | CGPoint center = CGPointZero; 61 | UIImage *image; 62 | 63 | 64 | switch (i) { 65 | case 0: 66 | // 圆形五个按钮 上下左右 中心 67 | 68 | center=CGPointMake(CGRectGetMidX(self.view.frame), height+CGRectGetHeight(buttonView.frame)/2); 69 | 70 | break; 71 | 72 | break; 73 | case 1: 74 | // 单个圆形按钮 只响应 SelectButtonPosition_Center 75 | 76 | 77 | image=[UIImage imageNamed:@"virtual_control_switch"]; 78 | center=CGPointMake(CGRectGetMidX(self.view.frame)/2.0, height+image.size.width/2); 79 | 80 | 81 | break; 82 | case 2: 83 | // 圆角按钮 只响应 SelectButtonPosition_Center 84 | image=[UIImage imageNamed:@"virtual_control_number"]; 85 | center=CGPointMake(CGRectGetMidX(self.view.frame)/2.0, height+image.size.height/2); 86 | 87 | 88 | break; 89 | case 3: 90 | // 竖加减 只响应 SelectButtonPosition_Buttom SelectButtonPosition_Top, 91 | 92 | center=CGPointMake(CGRectGetMidX(self.view.frame)/2.0*3, height-CGRectGetHeight(buttonView.frame)/2-30); 93 | 94 | 95 | break; 96 | case 4: 97 | // 横加减 只响应 SelectButtonPosition_Right SelectButtonPosition_Left, 98 | 99 | 100 | center=CGPointMake(CGRectGetMidX(self.view.frame), height+CGRectGetHeight(buttonView.frame)/2); 101 | 102 | 103 | break; 104 | 105 | 106 | default: 107 | break; 108 | } 109 | 110 | 111 | 112 | if (image) { 113 | 114 | [buttonView setImage:image]; 115 | } 116 | 117 | [buttonView setTitle:[titleArray objectAtIndex:i]]; 118 | buttonView.center=center; 119 | buttonView.tag=i; 120 | height=CGRectGetMaxY(buttonView.frame)+30; 121 | 122 | 123 | } 124 | 125 | } 126 | 127 | 128 | 129 | #pragma mark - 按钮单击事件 130 | -(void)buttonClick:(ZAShapeButton *)button 131 | { 132 | 133 | 134 | NSString *string=[NSString stringWithFormat:@"单击事件,按钮 tag 值 ‘%zd’ 点击位置 ‘%@’",button.tag,[self getSelectPartStringWithButtonView:button ]]; 135 | 136 | showLabel.text=string; 137 | // 138 | // UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:string delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; 139 | // [alert show]; 140 | 141 | 142 | } 143 | 144 | 145 | 146 | #pragma mark - 按钮长按事件 147 | -(void)longPressButtonClick:(ZAShapeButton *)button 148 | { 149 | 150 | 151 | NSString *string=[NSString stringWithFormat:@"长按事件,按钮 tag 值 ‘%zd’ 点击位置 ‘%@’",button.tag,[self getSelectPartStringWithButtonView:button ]]; 152 | 153 | 154 | showLabel.text=string; 155 | 156 | // UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:string delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; 157 | // [alert show]; 158 | 159 | 160 | } 161 | 162 | 163 | #pragma mark - 获取选中位置 164 | -(NSString *)getSelectPartStringWithButtonView:(ZAShapeButton *)button 165 | { 166 | NSString *partString; 167 | 168 | 169 | switch (button.selectButtonPosition) { 170 | case SelectButtonPositionTop: 171 | 172 | partString=@"上"; 173 | break; 174 | case SelectButtonPositionButtom: 175 | partString=@"下"; 176 | break; 177 | case SelectButtonPositionCenter: 178 | 179 | partString=@"中"; 180 | break; 181 | case SelectButtonPositionLeft: 182 | partString=@"左"; 183 | break; 184 | case SelectButtonPositionRight: 185 | partString=@"右"; 186 | break; 187 | default: 188 | break; 189 | } 190 | 191 | 192 | return partString; 193 | 194 | 195 | } 196 | 197 | - (void)didReceiveMemoryWarning { 198 | [super didReceiveMemoryWarning]; 199 | // Dispose of any resources that can be recreated. 200 | } 201 | 202 | @end 203 | -------------------------------------------------------------------------------- /ZAShapeButton/ZAShapeButton.xcdatamodeld/.xccurrentversion: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | _XCCurrentVersionName 6 | ZAShapeButton.xcdatamodel 7 | 8 | 9 | -------------------------------------------------------------------------------- /ZAShapeButton/ZAShapeButton.xcdatamodeld/ZAShapeButton.xcdatamodel/contents: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ZAShapeButton/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ZAShapeButton 4 | // 5 | // Created by zhuoapp on 15/7/1. 6 | // Copyright (c) 2015年 zhuoapp. 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 | -------------------------------------------------------------------------------- /ZAShapeButtonTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ZAShapeButtonTests/ZAShapeButtonTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZAShapeButtonTests.m 3 | // ZAShapeButtonTests 4 | // 5 | // Created by zhuoapp on 15/7/1. 6 | // Copyright (c) 2015年 zhuoapp. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface ZAShapeButtonTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation ZAShapeButtonTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------