├── .gitignore ├── LICENSE ├── README.md ├── SCPromptView.graffle ├── SCPromptView.podspec ├── SCPromptView ├── SCPromptView.h └── SCPromptView.m └── demo ├── SCPromptViewDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── SCPromptViewDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── class_mark.imageset │ │ ├── Contents.json │ │ └── class_mark@2x.png │ ├── error.imageset │ │ ├── Contents.json │ │ └── tgy_VideoClose@2X.png │ └── success.imageset │ │ ├── Contents.json │ │ └── tgy_video_confirm@2x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ResultPromptView.h ├── ResultPromptView.m ├── RootViewController.h ├── RootViewController.m ├── TestPromptView.h ├── TestPromptView.m ├── ViewController.h ├── ViewController.m └── main.m ├── SCPromptViewDemoTests ├── Info.plist └── SCPromptViewDemoTests.m └── SCPromptViewDemoUITests ├── Info.plist └── SCPromptViewDemoUITests.m /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 陈小翰 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SCPromptView 2 | ![](https://upload-images.jianshu.io/upload_images/2170902-41022bef50f9b131.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 3 | 4 | [SCPromptView](https://github.com/Chan4iOS/SCPromptView) : 显示在顶部的提示控件 5 | [SCPromptView-Swift](https://github.com/Chan4iOS/SCPromptView-Swift) 6 | 7 | >**你的star是我最大的动力** 8 | 9 | 10 | 11 | 12 | ## 安装 13 | ### 手动安装 14 | 下载源码,将`SCPromptView `文件夹拖进项目 15 | 16 | ### CocoaPod 17 | ``` 18 | pod 'SCPromptView' 19 | ``` 20 | 21 | ## 使用 22 | SCPromptView 的用法,与tableView相似 23 | #### 创建view 24 | ``` 25 | #import "SCPromptView.h" 26 | 27 | @interface TestPromptView : SCPromptView 28 | 29 | @end 30 | #import "TestPromptView.h" 31 | 32 | @interface TestPromptView() 33 | /** 34 | * label 35 | */ 36 | @property (nonatomic,strong)UILabel *textLabel; 37 | @end 38 | 39 | @implementation TestPromptView 40 | //初始化子控件 41 | -(void)sc_setUpCustomSubViews{ 42 | self.backgroundColor= [UIColor colorWithRed:(arc4random()%255)/255.f green:(arc4random()%255)/255.f blue:(arc4random()%255)/255.f alpha:1]; 43 | UILabel *textLabel = [[UILabel alloc]initWithFrame:self.contentView.bounds]; 44 | textLabel.textColor = [UIColor whiteColor]; 45 | textLabel.textAlignment = NSTextAlignmentCenter; 46 | [self.contentView addSubview:textLabel]; 47 | self.textLabel = textLabel; 48 | } 49 | //读取参数 50 | -(void)sc_loadParam:(id)param{ 51 | NSString *text = param; 52 | self.textLabel.text = text; 53 | } 54 | @end 55 | ``` 56 | 重写两个基础方法 57 | 58 | #### 注册 59 | ``` 60 | SCPROMPT_REGISTER([TestPromptView class],@"test") 61 | SCPROMPT_REGISTER([ResultPromptView class], @"result") 62 | ``` 63 | #### 发送显示命令 64 | ``` 65 | ///随机颜色显示 66 | -(void)clickBtn:(id)sender{ 67 | NSString * text =[NSString stringWithFormat:@"%d",_num]; 68 | SCPROMPT_SHOW(@"test",text) 69 | _num++; 70 | } 71 | ``` 72 | 73 | ## 其他Api 74 | ``` 75 | @protocol SCPromptViewDelegate 76 | @required 77 | /** 78 | * @brief 添加自定义的子控件 79 | */ 80 | -(void)sc_setUpCustomSubViews; 81 | /** 82 | * @brief 子控件读取数据 83 | */ 84 | -(void)sc_loadParam:(id)param; 85 | 86 | @optional 87 | /** 88 | * @brief 显示时间 89 | */ 90 | -(NSTimeInterval)sc_showTime; 91 | /** 92 | * @brief 滑动距离 93 | */ 94 | -(CGFloat)sc_slideDistance; 95 | /** 96 | * @brief 震动距离 97 | */ 98 | -(CGFloat)sc_shakeDistance; 99 | /** 100 | * @brief 出现动画时间 101 | */ 102 | -(NSTimeInterval)sc_showAnimationDuration; 103 | /** 104 | * @brief 隐藏动画时间 105 | */ 106 | -(NSTimeInterval)sc_hideAnimationDuration; 107 | /** 108 | * @brief 即将执行由手势触发的隐藏 109 | * @return yes 隐藏 / no 不隐藏 110 | */ 111 | -(BOOL)sc_willHideByTap; 112 | 113 | @end 114 | ``` 115 | 116 | 117 | # SCPromptView 118 | [SCPromptView](https://github.com/Chan4iOS/SCPromptView) : A prompt view which show in the top of the screen . 119 | 120 | 121 | >**Your star is my biggest motivation.** 122 | 123 | 126 | 127 | ## Install 128 | ### Manually 129 | Download the source code , copy folder `SCPromptView` into your project. 130 | ### CocoaPod 131 | ``` 132 | pod 'SCPromptView' 133 | ``` 134 | 135 | ## Usage 136 | The usage of SCPromptView is similar to the usage of UITableView. 137 | #### Create Custom View 138 | ``` 139 | #import "SCPromptView.h" 140 | 141 | @interface TestPromptView : SCPromptView 142 | 143 | @end 144 | #import "TestPromptView.h" 145 | 146 | @interface TestPromptView() 147 | /** 148 | * label 149 | */ 150 | @property (nonatomic,strong)UILabel *textLabel; 151 | @end 152 | 153 | @implementation TestPromptView 154 | //setUp subviews 155 | -(void)sc_setUpCustomSubViews{ 156 | self.backgroundColor= [UIColor colorWithRed:(arc4random()%255)/255.f green:(arc4random()%255)/255.f blue:(arc4random()%255)/255.f alpha:1]; 157 | UILabel *textLabel = [[UILabel alloc]initWithFrame:self.contentView.bounds]; 158 | textLabel.textColor = [UIColor whiteColor]; 159 | textLabel.textAlignment = NSTextAlignmentCenter; 160 | [self.contentView addSubview:textLabel]; 161 | self.textLabel = textLabel; 162 | } 163 | //loadParam which you deliver via command 164 | -(void)sc_loadParam:(id)param{ 165 | NSString *text = param; 166 | self.textLabel.text = text; 167 | } 168 | @end 169 | ``` 170 | Override two basic function. 171 | 172 | #### Register 173 | ``` 174 | SCPROMPT_REGISTER([TestPromptView class],@"test") 175 | SCPROMPT_REGISTER([ResultPromptView class], @"result") 176 | ``` 177 | #### 发送显示命令 178 | ``` 179 | ///show random color 180 | -(void)clickBtn:(id)sender{ 181 | NSString * text =[NSString stringWithFormat:@"%d",_num]; 182 | SCPROMPT_SHOW(@"test",text) 183 | _num++; 184 | } 185 | ``` 186 | ## Other Api 187 | ``` 188 | @protocol SCPromptViewDelegate 189 | @required 190 | /** 191 | * @brief 添加自定义的子控件 192 | */ 193 | -(void)sc_setUpCustomSubViews; 194 | /** 195 | * @brief 子控件读取数据 196 | */ 197 | -(void)sc_loadParam:(id)param; 198 | 199 | @optional 200 | /** 201 | * @brief 显示时间 202 | */ 203 | -(NSTimeInterval)sc_showTime; 204 | /** 205 | * @brief 滑动距离 206 | */ 207 | -(CGFloat)sc_slideDistance; 208 | /** 209 | * @brief 震动距离 210 | */ 211 | -(CGFloat)sc_shakeDistance; 212 | /** 213 | * @brief 出现动画时间 214 | */ 215 | -(NSTimeInterval)sc_showAnimationDuration; 216 | /** 217 | * @brief 隐藏动画时间 218 | */ 219 | -(NSTimeInterval)sc_hideAnimationDuration; 220 | /** 221 | * @brief 即将执行由手势触发的隐藏 222 | * @return yes 隐藏 / no 不隐藏 223 | */ 224 | -(BOOL)sc_willHideByTap; 225 | 226 | @end 227 | ``` 228 | -------------------------------------------------------------------------------- /SCPromptView.graffle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kuah/SCPromptView/ade605d434631eb0d3525403f70a67736f675ed4/SCPromptView.graffle -------------------------------------------------------------------------------- /SCPromptView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'SCPromptView' 3 | s.version = '2.1.1' 4 | s.summary = 'A prompt view which show in the top of the screen .' 5 | s.homepage = 'https://github.com/Chan4iOS/SCPromptView' 6 | s.author = "CT4 => 284766710@qq.com" 7 | s.source = {:git => 'https://github.com/Chan4iOS/SCPromptView.git', :tag => "#{s.version}"} 8 | s.source_files = "SCPromptView/**/*.{h,m}" 9 | s.requires_arc = true 10 | s.ios.deployment_target = '7.0' 11 | s.license = 'MIT' 12 | end 13 | -------------------------------------------------------------------------------- /SCPromptView/SCPromptView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCPromptView.h 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/9. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | #define SCPROMPT_SHOW_COMMAND @"SCPROMPT_SHOW_COMMAND" 11 | 12 | #define SCPROMPT_SHOW(SHOWCOMMAND,PARAM) \ 13 | [[SCPromptManager sharedManager] showPromptViewWithCommand:SHOWCOMMAND param:PARAM]; 14 | 15 | #define SCPROMPT_REGISTER(_CLASS_,COMMANDKEY) \ 16 | [[SCPromptManager sharedManager] registerPromptViewWithClass:_CLASS_ forShowCommand:COMMANDKEY]; 17 | BOOL lt_iPhoneX(); 18 | #define SC_SUGGEST_TOP_PADDING (lt_iPhoneX()?30:20) 19 | 20 | @protocol SCPromptViewDelegate 21 | @required 22 | /** 23 | * @brief 添加自定义的子空间 24 | */ 25 | -(void)sc_setUpCustomSubViews; 26 | /** 27 | * @brief 子控件读取数据 28 | */ 29 | -(void)sc_loadParam:(id)param; 30 | 31 | @optional 32 | /** 33 | * @brief 显示时间 34 | */ 35 | -(NSTimeInterval)sc_showTime; 36 | /** 37 | * @brief 出现动画时间 38 | */ 39 | -(NSTimeInterval)sc_showAnimationDuration; 40 | /** 41 | * @brief 隐藏动画时间 42 | */ 43 | -(NSTimeInterval)sc_hideAnimationDuration; 44 | /** 45 | * @brief 即将执行由手势触发的隐藏 46 | * @return yes 隐藏 / no 不隐藏 47 | */ 48 | -(BOOL)sc_willHideByTap; 49 | 50 | @end 51 | 52 | @interface SCPromptView : UIView 53 | /** 54 | * 内容 55 | */ 56 | @property (nonatomic,strong)UIView *contentView; 57 | 58 | @end 59 | 60 | @interface SCPromptManager : NSObject 61 | 62 | +(instancetype)sharedManager; 63 | /** 64 | * @brief 注册样式类 65 | * @param viewClass 样式类 66 | * @param showCommand 显示命令 67 | */ 68 | -(void)registerPromptViewWithClass:(Class)viewClass forShowCommand:(NSString *)showCommand; 69 | /** 70 | * @brief 通知显示promptView 71 | * @param showCommand 绑定的显示命令 72 | * @param param 参数 73 | */ 74 | -(void)showPromptViewWithCommand:(NSString *)showCommand param:(id)param; 75 | 76 | @end 77 | 78 | -------------------------------------------------------------------------------- /SCPromptView/SCPromptView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCPromptView.m 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/9. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "SCPromptView.h" 10 | #define SC_SLIDE_DISTANCE 18 11 | #define SC_DEFAULT_SHOW_TIME 2 12 | #define SC_SHOW_ANIMATION_DURATION 0.35 13 | #define SC_HIDE_ANIMATION_DURATION 0.2 14 | #define SC_CONTENT_HEIGHT (lt_iPhoneX()?88:64) 15 | 16 | @interface SCPromptView () 17 | /** 18 | * <#decr#> 19 | */ 20 | @property (nonatomic,strong)NSString *showComand; 21 | @end 22 | 23 | @implementation SCPromptView 24 | -(instancetype)init{ 25 | self = [super init]; 26 | [self addSubview:self.contentView]; 27 | self.frame = (CGRect){0,0,[UIScreen mainScreen].bounds.size.width,SC_CONTENT_HEIGHT+[self sc_slideDistance]}; 28 | self.contentView.frame = (CGRect){0,[self sc_slideDistance],[UIScreen mainScreen].bounds.size.width,SC_CONTENT_HEIGHT}; 29 | return self; 30 | } 31 | -(UIView *)contentView{ 32 | if (!_contentView) { 33 | _contentView = [UIView new]; 34 | [self addSubview:_contentView]; 35 | } 36 | return _contentView; 37 | } 38 | /** 39 | * @brief 添加自定义的子空间 40 | */ 41 | -(void)sc_setUpCustomSubViews{ 42 | 43 | } 44 | /** 45 | * @brief 子控件读取数据 46 | */ 47 | -(void)sc_loadParam:(id)param{ 48 | 49 | } 50 | /** 51 | * @brief 显示时间 52 | */ 53 | -(NSTimeInterval)sc_showTime{ 54 | return SC_DEFAULT_SHOW_TIME; 55 | } 56 | 57 | /** 58 | * @brief 出现动画时间 59 | */ 60 | -(NSTimeInterval)sc_showAnimationDuration{ 61 | return SC_SHOW_ANIMATION_DURATION; 62 | } 63 | /** 64 | * @brief 隐藏动画时间 65 | */ 66 | -(NSTimeInterval)sc_hideAnimationDuration{ 67 | return SC_HIDE_ANIMATION_DURATION; 68 | } 69 | /** 70 | * @brief 即将执行由手势触发的隐藏 71 | * @return yes 隐藏 / no 不隐藏 72 | */ 73 | -(BOOL)sc_willHideByTap{ 74 | return YES; 75 | } 76 | /** 77 | * @brief 滑动距离 仅仅用于震动动画时候遮挡上一个的view 78 | */ 79 | -(CGFloat)sc_slideDistance{ 80 | return SC_SLIDE_DISTANCE; 81 | } 82 | @end 83 | 84 | @interface SCPromptManager() 85 | /** 86 | * 注册信息 87 | */ 88 | @property (nonatomic,strong)NSMutableDictionary *registerInfo; 89 | /** 90 | * 重用池 91 | */ 92 | @property (nonatomic,strong)NSMutableDictionary *reusableViewPool; 93 | /** 94 | * 当前显示的view 95 | */ 96 | @property (nonatomic,strong)SCPromptView *showingView; 97 | @end 98 | 99 | @implementation SCPromptManager 100 | 101 | -(NSMutableDictionary *)registerInfo{ 102 | if (!_registerInfo) { 103 | _registerInfo = [NSMutableDictionary dictionary]; 104 | } 105 | return _registerInfo; 106 | } 107 | -(NSMutableDictionary *)reusableViewPool{ 108 | if (!_reusableViewPool) { 109 | _reusableViewPool = [NSMutableDictionary dictionary]; 110 | } 111 | return _reusableViewPool; 112 | } 113 | +(instancetype)sharedManager{ 114 | static SCPromptManager *_coreManager; 115 | static dispatch_once_t onceToken; 116 | dispatch_once(&onceToken, ^{ 117 | _coreManager = [[SCPromptManager alloc] init]; 118 | [_coreManager setUp]; 119 | }); 120 | return _coreManager; 121 | } 122 | /** 123 | * @brief 初始化 124 | */ 125 | -(void)setUp{ 126 | //添加接受命令观察者 127 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceivedShowCommand:) name:SCPROMPT_SHOW_COMMAND object:nil]; 128 | } 129 | /** 130 | * @brief 注册视图类 必须为SCPromptView或子类 131 | * @param viewClass 视图类别 132 | * @param showCommand 显示命令 133 | */ 134 | -(void)registerPromptViewWithClass:(Class)viewClass forShowCommand:(NSString *)showCommand{ 135 | NSAssert([viewClass isSubclassOfClass:[SCPromptView class]], @"注册的classs必须为SCPromptView的子类"); 136 | [self.registerInfo setObject:NSStringFromClass(viewClass) forKey:showCommand]; 137 | } 138 | /** 139 | * @brief 通知显示promptView 140 | * @param showCommand 绑定的显示命令 141 | * @param param 参数 142 | */ 143 | -(void)showPromptViewWithCommand:(NSString *)showCommand param:(id)param{ 144 | [[NSNotificationCenter defaultCenter] postNotificationName:SCPROMPT_SHOW_COMMAND object:param userInfo:@{SCPROMPT_SHOW_COMMAND:showCommand}]; 145 | } 146 | /** 147 | * @brief 接收到显示命令 148 | * @param notification 命令通知 149 | */ 150 | -(void)didReceivedShowCommand:(NSNotification *)notification{ 151 | NSString *showCommand = notification.userInfo[SCPROMPT_SHOW_COMMAND]; 152 | id param = notification.object; 153 | if ([NSThread isMainThread]) { 154 | [self matchWithShowCommand:showCommand param:param]; 155 | }else{ 156 | dispatch_async(dispatch_get_main_queue(), ^{ 157 | [self matchWithShowCommand:showCommand param:param]; 158 | }); 159 | } 160 | } 161 | /** 162 | * @brief 匹配显示命令和参数 163 | * @param showCommand 显示命令 164 | * @param param 参数 165 | */ 166 | -(void)matchWithShowCommand:(NSString *)showCommand param:(id)param{ 167 | NSString *className = self.registerInfo[showCommand]; 168 | if (!className) { 169 | NSCAssert(0, @"showCommand:%@ 没有被注册",showCommand); 170 | }else{ 171 | //生成 172 | SCPromptView *promptView = [self getReusableView:showCommand]; 173 | if ([promptView respondsToSelector:@selector(sc_loadParam:)]) { 174 | [promptView sc_loadParam:param]; 175 | } 176 | //显示 177 | promptView.frame = (CGRect){0,-SC_CONTENT_HEIGHT-[promptView sc_slideDistance],[UIScreen mainScreen].bounds.size.width,SC_CONTENT_HEIGHT+[promptView sc_slideDistance]}; 178 | promptView.contentView.frame = (CGRect){0,[promptView sc_slideDistance],[UIScreen mainScreen].bounds.size.width,SC_CONTENT_HEIGHT}; 179 | [self showInWindow:promptView]; 180 | } 181 | } 182 | 183 | /** 184 | * @brief 获取重用的view 185 | * @param showCommand 唯一的显示命令 186 | * @return SCPromptView 187 | */ 188 | -(SCPromptView *)getReusableView:(NSString *)showCommand{ 189 | NSMutableArray *queueForCommand = self.reusableViewPool[showCommand]; 190 | if (queueForCommand && queueForCommand.count>1) { 191 | SCPromptView *reusableView = queueForCommand.firstObject; 192 | [queueForCommand removeObject:reusableView]; 193 | self.reusableViewPool[showCommand] = queueForCommand; 194 | return reusableView; 195 | }else{ 196 | NSString *className = self.registerInfo[showCommand]; 197 | Class viewClass = NSClassFromString(className); 198 | //生成 199 | SCPromptView *promptView = [[viewClass alloc]init]; 200 | if ([promptView respondsToSelector:@selector(sc_setUpCustomSubViews)]) { 201 | [promptView sc_setUpCustomSubViews]; 202 | } 203 | promptView.showComand = showCommand; 204 | 205 | return promptView; 206 | } 207 | } 208 | -(void)tapToHide:(UITapGestureRecognizer *)target{ 209 | SCPromptView *promptView = (SCPromptView *)target.view; 210 | if ([promptView sc_willHideByTap]) { 211 | [self hideInWindow:promptView]; 212 | } 213 | } 214 | /** 215 | * @brief 显示 216 | * @param promptView 显示的视图 217 | */ 218 | -(void)showInWindow:(SCPromptView *)promptView{ 219 | [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideInWindow:) object:nil]; 220 | [[[UIApplication sharedApplication].delegate window] addSubview:promptView]; 221 | if (!promptView.gestureRecognizers || promptView.gestureRecognizers.count==0) { 222 | [promptView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapToHide:)]]; 223 | } 224 | [UIView animateWithDuration:[promptView sc_showAnimationDuration] delay:0 usingSpringWithDamping:0.5f initialSpringVelocity:0.0 options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveEaseInOut animations:^{ 225 | promptView.frame = (CGRect){0,-[promptView sc_slideDistance],promptView.bounds.size}; 226 | } completion:^(BOOL finished) { 227 | [self delayhideInWindow:promptView]; 228 | }]; 229 | } 230 | /** 231 | * @brief 动画式隐藏 232 | * @param promptView 隐藏的视图 233 | */ 234 | -(void)delayhideInWindow:(SCPromptView *)promptView{ 235 | if(!promptView.superview){ 236 | return; 237 | } 238 | //关闭之前的收起的请求 239 | [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideInWindow:) object:promptView]; 240 | //设置showingView,把后面的直接从window remove 241 | self.showingView = promptView; 242 | [self performSelector:@selector(hideInWindow:) withObject:promptView afterDelay:[promptView sc_showTime] ]; 243 | } 244 | /** 245 | * @brief 动画隐藏promptView 246 | * @param promptView 隐藏的view 247 | */ 248 | -(void)hideInWindow:(SCPromptView *)promptView{ 249 | //不是最顶层的view则不管 250 | if (self.showingView != promptView)return; 251 | [UIView animateWithDuration:[promptView sc_hideAnimationDuration] animations:^{ 252 | promptView.frame = (CGRect){0,-SC_CONTENT_HEIGHT-[promptView sc_slideDistance],promptView.bounds.size}; 253 | } completion:^(BOOL finished) { 254 | [self hideInWindowDirectly:promptView]; 255 | }]; 256 | } 257 | /** 258 | * @brief 直接隐藏 259 | * @param promptView 隐藏的视图 260 | */ 261 | -(void)hideInWindowDirectly:(SCPromptView *)promptView{ 262 | if(!promptView.superview) return; 263 | [promptView removeFromSuperview]; 264 | NSMutableArray *queueForCommand = self.reusableViewPool[promptView.showComand]; 265 | if (!queueForCommand)queueForCommand = [NSMutableArray array]; 266 | [queueForCommand addObject:promptView]; 267 | [self.reusableViewPool setObject:queueForCommand forKey:promptView.showComand]; 268 | } 269 | /** 270 | * @brief 设置当前正在显示的视图 271 | * @param showingView 正在显示的视图 272 | */ 273 | -(void)setShowingView:(SCPromptView *)showingView{ 274 | SCPromptView *currentShowingView = _showingView; 275 | if (currentShowingView) { 276 | [self hideInWindowDirectly:currentShowingView]; 277 | } 278 | _showingView = showingView; 279 | } 280 | BOOL lt_iPhoneX(){ 281 | CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame]; 282 | if (statusBarFrame.size.height > 20.f) { 283 | return YES; 284 | } 285 | return NO; 286 | } 287 | @end 288 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 64D87EAF1E71B2EE00AFCEDB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 64D87EAE1E71B2EE00AFCEDB /* main.m */; }; 11 | 64D87EB21E71B2EE00AFCEDB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 64D87EB11E71B2EE00AFCEDB /* AppDelegate.m */; }; 12 | 64D87EB51E71B2EE00AFCEDB /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 64D87EB41E71B2EE00AFCEDB /* ViewController.m */; }; 13 | 64D87EB81E71B2EE00AFCEDB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 64D87EB61E71B2EE00AFCEDB /* Main.storyboard */; }; 14 | 64D87EBA1E71B2EE00AFCEDB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 64D87EB91E71B2EE00AFCEDB /* Assets.xcassets */; }; 15 | 64D87EBD1E71B2EE00AFCEDB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 64D87EBB1E71B2EE00AFCEDB /* LaunchScreen.storyboard */; }; 16 | 64D87EC81E71B2EE00AFCEDB /* SCPromptViewDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 64D87EC71E71B2EE00AFCEDB /* SCPromptViewDemoTests.m */; }; 17 | 64D87ED31E71B2EF00AFCEDB /* SCPromptViewDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 64D87ED21E71B2EF00AFCEDB /* SCPromptViewDemoUITests.m */; }; 18 | 64D87EE61E71C57C00AFCEDB /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 64D87EE51E71C57C00AFCEDB /* RootViewController.m */; }; 19 | 64D87EE91E72444200AFCEDB /* TestPromptView.m in Sources */ = {isa = PBXBuildFile; fileRef = 64D87EE81E72444200AFCEDB /* TestPromptView.m */; }; 20 | 64D87EF51E7252BA00AFCEDB /* SCPromptView.m in Sources */ = {isa = PBXBuildFile; fileRef = 64D87EF41E7252BA00AFCEDB /* SCPromptView.m */; }; 21 | 64D87EF81E725D0200AFCEDB /* ResultPromptView.m in Sources */ = {isa = PBXBuildFile; fileRef = 64D87EF71E725D0200AFCEDB /* ResultPromptView.m */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | 64D87EC41E71B2EE00AFCEDB /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = 64D87EA21E71B2EE00AFCEDB /* Project object */; 28 | proxyType = 1; 29 | remoteGlobalIDString = 64D87EA91E71B2EE00AFCEDB; 30 | remoteInfo = SCPromptViewDemo; 31 | }; 32 | 64D87ECF1E71B2EF00AFCEDB /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 64D87EA21E71B2EE00AFCEDB /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = 64D87EA91E71B2EE00AFCEDB; 37 | remoteInfo = SCPromptViewDemo; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | 64D87EAA1E71B2EE00AFCEDB /* SCPromptViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SCPromptViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 64D87EAE1E71B2EE00AFCEDB /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 44 | 64D87EB01E71B2EE00AFCEDB /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 45 | 64D87EB11E71B2EE00AFCEDB /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 46 | 64D87EB31E71B2EE00AFCEDB /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 47 | 64D87EB41E71B2EE00AFCEDB /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 48 | 64D87EB71E71B2EE00AFCEDB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 49 | 64D87EB91E71B2EE00AFCEDB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 50 | 64D87EBC1E71B2EE00AFCEDB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 51 | 64D87EBE1E71B2EE00AFCEDB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 64D87EC31E71B2EE00AFCEDB /* SCPromptViewDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SCPromptViewDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 64D87EC71E71B2EE00AFCEDB /* SCPromptViewDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SCPromptViewDemoTests.m; sourceTree = ""; }; 54 | 64D87EC91E71B2EE00AFCEDB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 64D87ECE1E71B2EF00AFCEDB /* SCPromptViewDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SCPromptViewDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | 64D87ED21E71B2EF00AFCEDB /* SCPromptViewDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SCPromptViewDemoUITests.m; sourceTree = ""; }; 57 | 64D87ED41E71B2EF00AFCEDB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 58 | 64D87EE41E71C57C00AFCEDB /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 59 | 64D87EE51E71C57C00AFCEDB /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = ""; }; 60 | 64D87EE71E72444200AFCEDB /* TestPromptView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestPromptView.h; sourceTree = ""; }; 61 | 64D87EE81E72444200AFCEDB /* TestPromptView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestPromptView.m; sourceTree = ""; }; 62 | 64D87EF31E7252BA00AFCEDB /* SCPromptView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCPromptView.h; sourceTree = ""; }; 63 | 64D87EF41E7252BA00AFCEDB /* SCPromptView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCPromptView.m; sourceTree = ""; }; 64 | 64D87EF61E725D0200AFCEDB /* ResultPromptView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResultPromptView.h; sourceTree = ""; }; 65 | 64D87EF71E725D0200AFCEDB /* ResultPromptView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ResultPromptView.m; sourceTree = ""; }; 66 | /* End PBXFileReference section */ 67 | 68 | /* Begin PBXFrameworksBuildPhase section */ 69 | 64D87EA71E71B2EE00AFCEDB /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | 64D87EC01E71B2EE00AFCEDB /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | 64D87ECB1E71B2EF00AFCEDB /* Frameworks */ = { 84 | isa = PBXFrameworksBuildPhase; 85 | buildActionMask = 2147483647; 86 | files = ( 87 | ); 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | /* End PBXFrameworksBuildPhase section */ 91 | 92 | /* Begin PBXGroup section */ 93 | 64D87EA11E71B2EE00AFCEDB = { 94 | isa = PBXGroup; 95 | children = ( 96 | 64D87EAC1E71B2EE00AFCEDB /* SCPromptViewDemo */, 97 | 64D87EC61E71B2EE00AFCEDB /* SCPromptViewDemoTests */, 98 | 64D87ED11E71B2EF00AFCEDB /* SCPromptViewDemoUITests */, 99 | 64D87EAB1E71B2EE00AFCEDB /* Products */, 100 | ); 101 | sourceTree = ""; 102 | }; 103 | 64D87EAB1E71B2EE00AFCEDB /* Products */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 64D87EAA1E71B2EE00AFCEDB /* SCPromptViewDemo.app */, 107 | 64D87EC31E71B2EE00AFCEDB /* SCPromptViewDemoTests.xctest */, 108 | 64D87ECE1E71B2EF00AFCEDB /* SCPromptViewDemoUITests.xctest */, 109 | ); 110 | name = Products; 111 | sourceTree = ""; 112 | }; 113 | 64D87EAC1E71B2EE00AFCEDB /* SCPromptViewDemo */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | 64D87EF21E7252BA00AFCEDB /* SCPromptView */, 117 | 64D87EB01E71B2EE00AFCEDB /* AppDelegate.h */, 118 | 64D87EB11E71B2EE00AFCEDB /* AppDelegate.m */, 119 | 64D87EB31E71B2EE00AFCEDB /* ViewController.h */, 120 | 64D87EB41E71B2EE00AFCEDB /* ViewController.m */, 121 | 64D87EF61E725D0200AFCEDB /* ResultPromptView.h */, 122 | 64D87EF71E725D0200AFCEDB /* ResultPromptView.m */, 123 | 64D87EE71E72444200AFCEDB /* TestPromptView.h */, 124 | 64D87EE81E72444200AFCEDB /* TestPromptView.m */, 125 | 64D87EE41E71C57C00AFCEDB /* RootViewController.h */, 126 | 64D87EE51E71C57C00AFCEDB /* RootViewController.m */, 127 | 64D87EB61E71B2EE00AFCEDB /* Main.storyboard */, 128 | 64D87EB91E71B2EE00AFCEDB /* Assets.xcassets */, 129 | 64D87EBB1E71B2EE00AFCEDB /* LaunchScreen.storyboard */, 130 | 64D87EBE1E71B2EE00AFCEDB /* Info.plist */, 131 | 64D87EAD1E71B2EE00AFCEDB /* Supporting Files */, 132 | ); 133 | path = SCPromptViewDemo; 134 | sourceTree = ""; 135 | }; 136 | 64D87EAD1E71B2EE00AFCEDB /* Supporting Files */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | 64D87EAE1E71B2EE00AFCEDB /* main.m */, 140 | ); 141 | name = "Supporting Files"; 142 | sourceTree = ""; 143 | }; 144 | 64D87EC61E71B2EE00AFCEDB /* SCPromptViewDemoTests */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | 64D87EC71E71B2EE00AFCEDB /* SCPromptViewDemoTests.m */, 148 | 64D87EC91E71B2EE00AFCEDB /* Info.plist */, 149 | ); 150 | path = SCPromptViewDemoTests; 151 | sourceTree = ""; 152 | }; 153 | 64D87ED11E71B2EF00AFCEDB /* SCPromptViewDemoUITests */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | 64D87ED21E71B2EF00AFCEDB /* SCPromptViewDemoUITests.m */, 157 | 64D87ED41E71B2EF00AFCEDB /* Info.plist */, 158 | ); 159 | path = SCPromptViewDemoUITests; 160 | sourceTree = ""; 161 | }; 162 | 64D87EF21E7252BA00AFCEDB /* SCPromptView */ = { 163 | isa = PBXGroup; 164 | children = ( 165 | 64D87EF31E7252BA00AFCEDB /* SCPromptView.h */, 166 | 64D87EF41E7252BA00AFCEDB /* SCPromptView.m */, 167 | ); 168 | name = SCPromptView; 169 | path = ../../SCPromptView; 170 | sourceTree = ""; 171 | }; 172 | /* End PBXGroup section */ 173 | 174 | /* Begin PBXNativeTarget section */ 175 | 64D87EA91E71B2EE00AFCEDB /* SCPromptViewDemo */ = { 176 | isa = PBXNativeTarget; 177 | buildConfigurationList = 64D87ED71E71B2EF00AFCEDB /* Build configuration list for PBXNativeTarget "SCPromptViewDemo" */; 178 | buildPhases = ( 179 | 64D87EA61E71B2EE00AFCEDB /* Sources */, 180 | 64D87EA71E71B2EE00AFCEDB /* Frameworks */, 181 | 64D87EA81E71B2EE00AFCEDB /* Resources */, 182 | ); 183 | buildRules = ( 184 | ); 185 | dependencies = ( 186 | ); 187 | name = SCPromptViewDemo; 188 | productName = SCPromptViewDemo; 189 | productReference = 64D87EAA1E71B2EE00AFCEDB /* SCPromptViewDemo.app */; 190 | productType = "com.apple.product-type.application"; 191 | }; 192 | 64D87EC21E71B2EE00AFCEDB /* SCPromptViewDemoTests */ = { 193 | isa = PBXNativeTarget; 194 | buildConfigurationList = 64D87EDA1E71B2EF00AFCEDB /* Build configuration list for PBXNativeTarget "SCPromptViewDemoTests" */; 195 | buildPhases = ( 196 | 64D87EBF1E71B2EE00AFCEDB /* Sources */, 197 | 64D87EC01E71B2EE00AFCEDB /* Frameworks */, 198 | 64D87EC11E71B2EE00AFCEDB /* Resources */, 199 | ); 200 | buildRules = ( 201 | ); 202 | dependencies = ( 203 | 64D87EC51E71B2EE00AFCEDB /* PBXTargetDependency */, 204 | ); 205 | name = SCPromptViewDemoTests; 206 | productName = SCPromptViewDemoTests; 207 | productReference = 64D87EC31E71B2EE00AFCEDB /* SCPromptViewDemoTests.xctest */; 208 | productType = "com.apple.product-type.bundle.unit-test"; 209 | }; 210 | 64D87ECD1E71B2EF00AFCEDB /* SCPromptViewDemoUITests */ = { 211 | isa = PBXNativeTarget; 212 | buildConfigurationList = 64D87EDD1E71B2EF00AFCEDB /* Build configuration list for PBXNativeTarget "SCPromptViewDemoUITests" */; 213 | buildPhases = ( 214 | 64D87ECA1E71B2EF00AFCEDB /* Sources */, 215 | 64D87ECB1E71B2EF00AFCEDB /* Frameworks */, 216 | 64D87ECC1E71B2EF00AFCEDB /* Resources */, 217 | ); 218 | buildRules = ( 219 | ); 220 | dependencies = ( 221 | 64D87ED01E71B2EF00AFCEDB /* PBXTargetDependency */, 222 | ); 223 | name = SCPromptViewDemoUITests; 224 | productName = SCPromptViewDemoUITests; 225 | productReference = 64D87ECE1E71B2EF00AFCEDB /* SCPromptViewDemoUITests.xctest */; 226 | productType = "com.apple.product-type.bundle.ui-testing"; 227 | }; 228 | /* End PBXNativeTarget section */ 229 | 230 | /* Begin PBXProject section */ 231 | 64D87EA21E71B2EE00AFCEDB /* Project object */ = { 232 | isa = PBXProject; 233 | attributes = { 234 | LastUpgradeCheck = 0820; 235 | ORGANIZATIONNAME = "Coder Chan"; 236 | TargetAttributes = { 237 | 64D87EA91E71B2EE00AFCEDB = { 238 | CreatedOnToolsVersion = 8.2.1; 239 | ProvisioningStyle = Automatic; 240 | }; 241 | 64D87EC21E71B2EE00AFCEDB = { 242 | CreatedOnToolsVersion = 8.2.1; 243 | ProvisioningStyle = Automatic; 244 | TestTargetID = 64D87EA91E71B2EE00AFCEDB; 245 | }; 246 | 64D87ECD1E71B2EF00AFCEDB = { 247 | CreatedOnToolsVersion = 8.2.1; 248 | ProvisioningStyle = Automatic; 249 | TestTargetID = 64D87EA91E71B2EE00AFCEDB; 250 | }; 251 | }; 252 | }; 253 | buildConfigurationList = 64D87EA51E71B2EE00AFCEDB /* Build configuration list for PBXProject "SCPromptViewDemo" */; 254 | compatibilityVersion = "Xcode 3.2"; 255 | developmentRegion = English; 256 | hasScannedForEncodings = 0; 257 | knownRegions = ( 258 | en, 259 | Base, 260 | ); 261 | mainGroup = 64D87EA11E71B2EE00AFCEDB; 262 | productRefGroup = 64D87EAB1E71B2EE00AFCEDB /* Products */; 263 | projectDirPath = ""; 264 | projectRoot = ""; 265 | targets = ( 266 | 64D87EA91E71B2EE00AFCEDB /* SCPromptViewDemo */, 267 | 64D87EC21E71B2EE00AFCEDB /* SCPromptViewDemoTests */, 268 | 64D87ECD1E71B2EF00AFCEDB /* SCPromptViewDemoUITests */, 269 | ); 270 | }; 271 | /* End PBXProject section */ 272 | 273 | /* Begin PBXResourcesBuildPhase section */ 274 | 64D87EA81E71B2EE00AFCEDB /* Resources */ = { 275 | isa = PBXResourcesBuildPhase; 276 | buildActionMask = 2147483647; 277 | files = ( 278 | 64D87EBD1E71B2EE00AFCEDB /* LaunchScreen.storyboard in Resources */, 279 | 64D87EBA1E71B2EE00AFCEDB /* Assets.xcassets in Resources */, 280 | 64D87EB81E71B2EE00AFCEDB /* Main.storyboard in Resources */, 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | }; 284 | 64D87EC11E71B2EE00AFCEDB /* Resources */ = { 285 | isa = PBXResourcesBuildPhase; 286 | buildActionMask = 2147483647; 287 | files = ( 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | }; 291 | 64D87ECC1E71B2EF00AFCEDB /* Resources */ = { 292 | isa = PBXResourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | /* End PBXResourcesBuildPhase section */ 299 | 300 | /* Begin PBXSourcesBuildPhase section */ 301 | 64D87EA61E71B2EE00AFCEDB /* Sources */ = { 302 | isa = PBXSourcesBuildPhase; 303 | buildActionMask = 2147483647; 304 | files = ( 305 | 64D87EB51E71B2EE00AFCEDB /* ViewController.m in Sources */, 306 | 64D87EE91E72444200AFCEDB /* TestPromptView.m in Sources */, 307 | 64D87EB21E71B2EE00AFCEDB /* AppDelegate.m in Sources */, 308 | 64D87EAF1E71B2EE00AFCEDB /* main.m in Sources */, 309 | 64D87EF51E7252BA00AFCEDB /* SCPromptView.m in Sources */, 310 | 64D87EF81E725D0200AFCEDB /* ResultPromptView.m in Sources */, 311 | 64D87EE61E71C57C00AFCEDB /* RootViewController.m in Sources */, 312 | ); 313 | runOnlyForDeploymentPostprocessing = 0; 314 | }; 315 | 64D87EBF1E71B2EE00AFCEDB /* Sources */ = { 316 | isa = PBXSourcesBuildPhase; 317 | buildActionMask = 2147483647; 318 | files = ( 319 | 64D87EC81E71B2EE00AFCEDB /* SCPromptViewDemoTests.m in Sources */, 320 | ); 321 | runOnlyForDeploymentPostprocessing = 0; 322 | }; 323 | 64D87ECA1E71B2EF00AFCEDB /* Sources */ = { 324 | isa = PBXSourcesBuildPhase; 325 | buildActionMask = 2147483647; 326 | files = ( 327 | 64D87ED31E71B2EF00AFCEDB /* SCPromptViewDemoUITests.m in Sources */, 328 | ); 329 | runOnlyForDeploymentPostprocessing = 0; 330 | }; 331 | /* End PBXSourcesBuildPhase section */ 332 | 333 | /* Begin PBXTargetDependency section */ 334 | 64D87EC51E71B2EE00AFCEDB /* PBXTargetDependency */ = { 335 | isa = PBXTargetDependency; 336 | target = 64D87EA91E71B2EE00AFCEDB /* SCPromptViewDemo */; 337 | targetProxy = 64D87EC41E71B2EE00AFCEDB /* PBXContainerItemProxy */; 338 | }; 339 | 64D87ED01E71B2EF00AFCEDB /* PBXTargetDependency */ = { 340 | isa = PBXTargetDependency; 341 | target = 64D87EA91E71B2EE00AFCEDB /* SCPromptViewDemo */; 342 | targetProxy = 64D87ECF1E71B2EF00AFCEDB /* PBXContainerItemProxy */; 343 | }; 344 | /* End PBXTargetDependency section */ 345 | 346 | /* Begin PBXVariantGroup section */ 347 | 64D87EB61E71B2EE00AFCEDB /* Main.storyboard */ = { 348 | isa = PBXVariantGroup; 349 | children = ( 350 | 64D87EB71E71B2EE00AFCEDB /* Base */, 351 | ); 352 | name = Main.storyboard; 353 | sourceTree = ""; 354 | }; 355 | 64D87EBB1E71B2EE00AFCEDB /* LaunchScreen.storyboard */ = { 356 | isa = PBXVariantGroup; 357 | children = ( 358 | 64D87EBC1E71B2EE00AFCEDB /* Base */, 359 | ); 360 | name = LaunchScreen.storyboard; 361 | sourceTree = ""; 362 | }; 363 | /* End PBXVariantGroup section */ 364 | 365 | /* Begin XCBuildConfiguration section */ 366 | 64D87ED51E71B2EF00AFCEDB /* Debug */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | ALWAYS_SEARCH_USER_PATHS = NO; 370 | CLANG_ANALYZER_NONNULL = YES; 371 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 372 | CLANG_CXX_LIBRARY = "libc++"; 373 | CLANG_ENABLE_MODULES = YES; 374 | CLANG_ENABLE_OBJC_ARC = YES; 375 | CLANG_WARN_BOOL_CONVERSION = YES; 376 | CLANG_WARN_CONSTANT_CONVERSION = YES; 377 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 378 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 379 | CLANG_WARN_EMPTY_BODY = YES; 380 | CLANG_WARN_ENUM_CONVERSION = YES; 381 | CLANG_WARN_INFINITE_RECURSION = YES; 382 | CLANG_WARN_INT_CONVERSION = YES; 383 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 384 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 385 | CLANG_WARN_UNREACHABLE_CODE = YES; 386 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 387 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 388 | COPY_PHASE_STRIP = NO; 389 | DEBUG_INFORMATION_FORMAT = dwarf; 390 | ENABLE_STRICT_OBJC_MSGSEND = YES; 391 | ENABLE_TESTABILITY = YES; 392 | GCC_C_LANGUAGE_STANDARD = gnu99; 393 | GCC_DYNAMIC_NO_PIC = NO; 394 | GCC_NO_COMMON_BLOCKS = YES; 395 | GCC_OPTIMIZATION_LEVEL = 0; 396 | GCC_PREPROCESSOR_DEFINITIONS = ( 397 | "DEBUG=1", 398 | "$(inherited)", 399 | ); 400 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 401 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 402 | GCC_WARN_UNDECLARED_SELECTOR = YES; 403 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 404 | GCC_WARN_UNUSED_FUNCTION = YES; 405 | GCC_WARN_UNUSED_VARIABLE = YES; 406 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 407 | MTL_ENABLE_DEBUG_INFO = YES; 408 | ONLY_ACTIVE_ARCH = YES; 409 | SDKROOT = iphoneos; 410 | }; 411 | name = Debug; 412 | }; 413 | 64D87ED61E71B2EF00AFCEDB /* Release */ = { 414 | isa = XCBuildConfiguration; 415 | buildSettings = { 416 | ALWAYS_SEARCH_USER_PATHS = NO; 417 | CLANG_ANALYZER_NONNULL = YES; 418 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 419 | CLANG_CXX_LIBRARY = "libc++"; 420 | CLANG_ENABLE_MODULES = YES; 421 | CLANG_ENABLE_OBJC_ARC = YES; 422 | CLANG_WARN_BOOL_CONVERSION = YES; 423 | CLANG_WARN_CONSTANT_CONVERSION = YES; 424 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 425 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 426 | CLANG_WARN_EMPTY_BODY = YES; 427 | CLANG_WARN_ENUM_CONVERSION = YES; 428 | CLANG_WARN_INFINITE_RECURSION = YES; 429 | CLANG_WARN_INT_CONVERSION = YES; 430 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 431 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 432 | CLANG_WARN_UNREACHABLE_CODE = YES; 433 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 434 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 435 | COPY_PHASE_STRIP = NO; 436 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 437 | ENABLE_NS_ASSERTIONS = NO; 438 | ENABLE_STRICT_OBJC_MSGSEND = YES; 439 | GCC_C_LANGUAGE_STANDARD = gnu99; 440 | GCC_NO_COMMON_BLOCKS = YES; 441 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 442 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 443 | GCC_WARN_UNDECLARED_SELECTOR = YES; 444 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 445 | GCC_WARN_UNUSED_FUNCTION = YES; 446 | GCC_WARN_UNUSED_VARIABLE = YES; 447 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 448 | MTL_ENABLE_DEBUG_INFO = NO; 449 | SDKROOT = iphoneos; 450 | VALIDATE_PRODUCT = YES; 451 | }; 452 | name = Release; 453 | }; 454 | 64D87ED81E71B2EF00AFCEDB /* Debug */ = { 455 | isa = XCBuildConfiguration; 456 | buildSettings = { 457 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 458 | INFOPLIST_FILE = SCPromptViewDemo/Info.plist; 459 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 460 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCPromptViewDemo; 461 | PRODUCT_NAME = "$(TARGET_NAME)"; 462 | }; 463 | name = Debug; 464 | }; 465 | 64D87ED91E71B2EF00AFCEDB /* Release */ = { 466 | isa = XCBuildConfiguration; 467 | buildSettings = { 468 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 469 | INFOPLIST_FILE = SCPromptViewDemo/Info.plist; 470 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 471 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCPromptViewDemo; 472 | PRODUCT_NAME = "$(TARGET_NAME)"; 473 | }; 474 | name = Release; 475 | }; 476 | 64D87EDB1E71B2EF00AFCEDB /* Debug */ = { 477 | isa = XCBuildConfiguration; 478 | buildSettings = { 479 | BUNDLE_LOADER = "$(TEST_HOST)"; 480 | INFOPLIST_FILE = SCPromptViewDemoTests/Info.plist; 481 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 482 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCPromptViewDemoTests; 483 | PRODUCT_NAME = "$(TARGET_NAME)"; 484 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SCPromptViewDemo.app/SCPromptViewDemo"; 485 | }; 486 | name = Debug; 487 | }; 488 | 64D87EDC1E71B2EF00AFCEDB /* Release */ = { 489 | isa = XCBuildConfiguration; 490 | buildSettings = { 491 | BUNDLE_LOADER = "$(TEST_HOST)"; 492 | INFOPLIST_FILE = SCPromptViewDemoTests/Info.plist; 493 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 494 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCPromptViewDemoTests; 495 | PRODUCT_NAME = "$(TARGET_NAME)"; 496 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SCPromptViewDemo.app/SCPromptViewDemo"; 497 | }; 498 | name = Release; 499 | }; 500 | 64D87EDE1E71B2EF00AFCEDB /* Debug */ = { 501 | isa = XCBuildConfiguration; 502 | buildSettings = { 503 | INFOPLIST_FILE = SCPromptViewDemoUITests/Info.plist; 504 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 505 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCPromptViewDemoUITests; 506 | PRODUCT_NAME = "$(TARGET_NAME)"; 507 | TEST_TARGET_NAME = SCPromptViewDemo; 508 | }; 509 | name = Debug; 510 | }; 511 | 64D87EDF1E71B2EF00AFCEDB /* Release */ = { 512 | isa = XCBuildConfiguration; 513 | buildSettings = { 514 | INFOPLIST_FILE = SCPromptViewDemoUITests/Info.plist; 515 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 516 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCPromptViewDemoUITests; 517 | PRODUCT_NAME = "$(TARGET_NAME)"; 518 | TEST_TARGET_NAME = SCPromptViewDemo; 519 | }; 520 | name = Release; 521 | }; 522 | /* End XCBuildConfiguration section */ 523 | 524 | /* Begin XCConfigurationList section */ 525 | 64D87EA51E71B2EE00AFCEDB /* Build configuration list for PBXProject "SCPromptViewDemo" */ = { 526 | isa = XCConfigurationList; 527 | buildConfigurations = ( 528 | 64D87ED51E71B2EF00AFCEDB /* Debug */, 529 | 64D87ED61E71B2EF00AFCEDB /* Release */, 530 | ); 531 | defaultConfigurationIsVisible = 0; 532 | defaultConfigurationName = Release; 533 | }; 534 | 64D87ED71E71B2EF00AFCEDB /* Build configuration list for PBXNativeTarget "SCPromptViewDemo" */ = { 535 | isa = XCConfigurationList; 536 | buildConfigurations = ( 537 | 64D87ED81E71B2EF00AFCEDB /* Debug */, 538 | 64D87ED91E71B2EF00AFCEDB /* Release */, 539 | ); 540 | defaultConfigurationIsVisible = 0; 541 | defaultConfigurationName = Release; 542 | }; 543 | 64D87EDA1E71B2EF00AFCEDB /* Build configuration list for PBXNativeTarget "SCPromptViewDemoTests" */ = { 544 | isa = XCConfigurationList; 545 | buildConfigurations = ( 546 | 64D87EDB1E71B2EF00AFCEDB /* Debug */, 547 | 64D87EDC1E71B2EF00AFCEDB /* Release */, 548 | ); 549 | defaultConfigurationIsVisible = 0; 550 | defaultConfigurationName = Release; 551 | }; 552 | 64D87EDD1E71B2EF00AFCEDB /* Build configuration list for PBXNativeTarget "SCPromptViewDemoUITests" */ = { 553 | isa = XCConfigurationList; 554 | buildConfigurations = ( 555 | 64D87EDE1E71B2EF00AFCEDB /* Debug */, 556 | 64D87EDF1E71B2EF00AFCEDB /* Release */, 557 | ); 558 | defaultConfigurationIsVisible = 0; 559 | defaultConfigurationName = Release; 560 | }; 561 | /* End XCConfigurationList section */ 562 | }; 563 | rootObject = 64D87EA21E71B2EE00AFCEDB /* Project object */; 564 | } 565 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/9. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/9. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "RootViewController.h" 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 | self.window.rootViewController = [[UINavigationController alloc]initWithRootViewController:[RootViewController new]]; 21 | [self.window makeKeyAndVisible]; 22 | return YES; 23 | } 24 | 25 | 26 | - (void)applicationWillResignActive:(UIApplication *)application { 27 | // 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. 28 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 29 | } 30 | 31 | 32 | - (void)applicationDidEnterBackground:(UIApplication *)application { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | 38 | - (void)applicationWillEnterForeground:(UIApplication *)application { 39 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 40 | } 41 | 42 | 43 | - (void)applicationDidBecomeActive:(UIApplication *)application { 44 | // 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. 45 | } 46 | 47 | 48 | - (void)applicationWillTerminate:(UIApplication *)application { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/Assets.xcassets/class_mark.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "class_mark@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/Assets.xcassets/class_mark.imageset/class_mark@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kuah/SCPromptView/ade605d434631eb0d3525403f70a67736f675ed4/demo/SCPromptViewDemo/Assets.xcassets/class_mark.imageset/class_mark@2x.png -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/Assets.xcassets/error.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tgy_VideoClose@2X.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/Assets.xcassets/error.imageset/tgy_VideoClose@2X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kuah/SCPromptView/ade605d434631eb0d3525403f70a67736f675ed4/demo/SCPromptViewDemo/Assets.xcassets/error.imageset/tgy_VideoClose@2X.png -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/Assets.xcassets/success.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tgy_video_confirm@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/Assets.xcassets/success.imageset/tgy_video_confirm@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kuah/SCPromptView/ade605d434631eb0d3525403f70a67736f675ed4/demo/SCPromptViewDemo/Assets.xcassets/success.imageset/tgy_video_confirm@2x.png -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/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 | 27 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/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 | 2.1 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/ResultPromptView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ResultPromptView.h 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/10. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "SCPromptView.h" 10 | 11 | @interface ResultPromptView : SCPromptView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/ResultPromptView.m: -------------------------------------------------------------------------------- 1 | // 2 | // ResultPromptView.m 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/10. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "ResultPromptView.h" 10 | 11 | @interface ResultPromptView() 12 | /** 13 | * <#decr#> 14 | */ 15 | @property (nonatomic,strong)UILabel *textLabel; 16 | /** 17 | * <#decr#> 18 | */ 19 | @property (nonatomic,strong)UIImageView *imageView; 20 | ; 21 | @end 22 | 23 | @implementation ResultPromptView 24 | -(void)sc_setUpCustomSubViews{ 25 | CGFloat topPadding = SC_SUGGEST_TOP_PADDING; 26 | UIImageView *imageView = [[UIImageView alloc]initWithFrame:(CGRect){22,SC_SUGGEST_TOP_PADDING+(self.contentView.bounds.size.height-20-SC_SUGGEST_TOP_PADDING)/2,20,20}]; 27 | [self.contentView addSubview:imageView]; 28 | self.imageView = imageView; 29 | self.backgroundColor = [UIColor whiteColor]; 30 | UILabel *textLabel = [[UILabel alloc]initWithFrame:(CGRect){50,topPadding,self.contentView.bounds.size.width-50,self.contentView.bounds.size.height-topPadding}]; 31 | textLabel.textColor = [UIColor lightGrayColor]; 32 | [self.contentView addSubview:textLabel]; 33 | self.textLabel = textLabel; 34 | 35 | } 36 | -(void)sc_loadParam:(id)param{ 37 | NSDictionary *dict = param; 38 | self.textLabel.text = dict[@"text"]; 39 | self.imageView.image = [dict[@"isSuccess"] boolValue]?[UIImage imageNamed:@"success"]:[UIImage imageNamed:@"error"]; 40 | } 41 | 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/RootViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RootViewController.h 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/10. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RootViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/RootViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RootViewController.m 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/10. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "RootViewController.h" 10 | #import "TestPromptView.h" 11 | #import "ResultPromptView.h" 12 | @interface RootViewController (){ 13 | int _num; 14 | } 15 | 16 | @end 17 | 18 | @implementation RootViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view. 23 | [self setUpDemoBtn]; 24 | self.view.backgroundColor = [UIColor colorWithRed:234/255.f green:234/255.f blue:234/255.f alpha:1]; 25 | SCPROMPT_REGISTER([TestPromptView class],@"test") 26 | SCPROMPT_REGISTER([ResultPromptView class], @"result") 27 | } 28 | ///随机颜色显示 29 | -(void)clickBtn:(id)sender{ 30 | NSString * text =[NSString stringWithFormat:@"%d",_num]; 31 | SCPROMPT_SHOW(@"test",text) 32 | _num++; 33 | } 34 | //成功 35 | -(void)showSuccess:(id)sender{ 36 | NSDictionary *param =@{@"text":@"操作成功",@"isSuccess":@(1)}; 37 | SCPROMPT_SHOW(@"result",param) 38 | } 39 | //失败 40 | -(void)showError:(id)sender{ 41 | NSDictionary *param =@{@"text":@"操作失败",@"isSuccess":@(0)}; 42 | SCPROMPT_SHOW(@"result",param) 43 | } 44 | 45 | 46 | /****************************** demo btn *********************************/ 47 | 48 | -(void)setUpDemoBtn{ 49 | CGFloat margin = [UIScreen mainScreen].bounds.size.width; 50 | UIButton *btn = [[UIButton alloc]initWithFrame:(CGRect){((margin-100)/2.f),200,100,50}]; 51 | [btn setTitle:@"提示" forState:UIControlStateNormal]; btn.backgroundColor = [UIColor redColor]; 52 | [btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside]; 53 | [self.view addSubview:btn]; 54 | 55 | UIButton *btn1 = [[UIButton alloc]initWithFrame:(CGRect){((margin-100)/2.f),300,100,50}]; 56 | [btn1 setTitle:@"成功" forState:UIControlStateNormal]; 57 | btn1.backgroundColor = [UIColor yellowColor]; 58 | [btn1 addTarget:self action:@selector(showSuccess:) forControlEvents:UIControlEventTouchUpInside]; 59 | [self.view addSubview:btn1]; 60 | 61 | UIButton *btn2 = [[UIButton alloc]initWithFrame:(CGRect){((margin-100)/2.f),400,100,50}]; 62 | [btn2 setTitle:@"失败" forState:UIControlStateNormal]; 63 | btn2.backgroundColor = [UIColor blueColor]; 64 | [btn2 addTarget:self action:@selector(showError:) forControlEvents:UIControlEventTouchUpInside]; 65 | [self.view addSubview:btn2]; 66 | } 67 | - (void)didReceiveMemoryWarning { 68 | [super didReceiveMemoryWarning]; 69 | // Dispose of any resources that can be recreated. 70 | } 71 | 72 | /* 73 | #pragma mark - Navigation 74 | 75 | // In a storyboard-based application, you will often want to do a little preparation before navigation 76 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 77 | // Get the new view controller using [segue destinationViewController]. 78 | // Pass the selected object to the new view controller. 79 | } 80 | */ 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/TestPromptView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestPromptView.h 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/10. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "SCPromptView.h" 10 | 11 | @interface TestPromptView : SCPromptView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/TestPromptView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestPromptView.m 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/10. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "TestPromptView.h" 10 | 11 | @interface TestPromptView() 12 | /** 13 | * <#decr#> 14 | */ 15 | @property (nonatomic,strong)UILabel *textLabel; 16 | @end 17 | 18 | @implementation TestPromptView 19 | -(void)sc_setUpCustomSubViews{ 20 | UILabel *textLabel = [[UILabel alloc]initWithFrame:(CGRect){0,SC_SUGGEST_TOP_PADDING,self.contentView.bounds.size.width,self.contentView.bounds.size.height-SC_SUGGEST_TOP_PADDING}]; 21 | textLabel.textColor = [UIColor whiteColor]; 22 | textLabel.textAlignment = NSTextAlignmentCenter; 23 | self.contentView.layer.cornerRadius = 5; 24 | self.contentView.layer.masksToBounds = YES; 25 | [self.contentView addSubview:textLabel]; 26 | self.textLabel = textLabel; 27 | } 28 | -(void)sc_loadParam:(id)param{ 29 | NSString *text = param; 30 | self.textLabel.text = text; 31 | UIColor *color = [UIColor colorWithRed:(arc4random()%255)/255.f green:(arc4random()%255)/255.f blue:(arc4random()%255)/255.f alpha:1]; 32 | self.backgroundColor=color; 33 | self.contentView.backgroundColor=color; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/9. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/9. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | 21 | } 22 | 23 | 24 | - (void)didReceiveMemoryWarning { 25 | [super didReceiveMemoryWarning]; 26 | // Dispose of any resources that can be recreated. 27 | } 28 | 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SCPromptViewDemo 4 | // 5 | // Created by 陈世翰 on 17/3/9. 6 | // Copyright © 2017年 Coder Chan. 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 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemoTests/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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemoTests/SCPromptViewDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCPromptViewDemoTests.m 3 | // SCPromptViewDemoTests 4 | // 5 | // Created by 陈世翰 on 17/3/9. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SCPromptViewDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SCPromptViewDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemoUITests/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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /demo/SCPromptViewDemoUITests/SCPromptViewDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCPromptViewDemoUITests.m 3 | // SCPromptViewDemoUITests 4 | // 5 | // Created by 陈世翰 on 17/3/9. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SCPromptViewDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SCPromptViewDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------