1 //UIActivityIndicatorView //小菊花,加载======================================================================================
2
3 #import "ActivityIndicatorVC.h"
4
5 @interface ActivityIndicatorVC (){
6 UIActivityIndicatorView *_activity ;
7 }
8
9 @end
10
11 @implementation ActivityIndicatorVC
12
13 -(void)viewDidLoad{
14 [super viewDidLoad];
15
16 [self createActivityIndicator];
17
18 }
19
20 -(void)createActivityIndicator{
21 //创建对象
22 _activity = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(100, 200, 100, 100)];
23
24 _activity.backgroundColor = [UIColor blackColor];
25
26 _activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
27
28 [self.view addSubview:_activity];
29
30 //让状态栏中的activityIndicator显示出来
31 [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
32
33 //开始动画
34 [_activity startAnimating];
35
36 }
37
38
39 // 想要停止的话添加
40 // [_activity stopAnimating];
41 //[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
42
43 @end
44
45 // UIProgressView //进度条======================================================================================================
46 #import "ProgressVC.h"
47
48
49
50 @implementation ProgressVC{
51 UIProgressView *_progress ;
52 NSTimer *_timer;
53 }
54
55
56 -(void)viewDidLoad{
57 [super viewDidLoad];
58
59 self.btn.hidden = YES;
60
61 [self createProgress];
62
63 [self createTimer];
64 }
65
66 -(void)createProgress{
67 _progress = [[UIProgressView alloc]initWithFrame:CGRectMake(50, 100, 200, 50)];
68 [self.view addSubview:_progress];
69 // progress.backgroundColor = [UIColor lightGrayColor];
70
71 _progress.tintColor = [UIColor redColor];
72
73 _progress.progressTintColor = [UIColor greenColor];
74 _progress.trackTintColor = [UIColor blueColor];
75
76 _progress.progress = 0.01;
77 }
78
79 -(void)createTimer{
80 _timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(run ) userInfo:nil repeats:YES];
81 }
82
83 -(void)run{
84 _progress.progress += 0.01;
85 }
86
87 @end
88
89
90 // UISegmentedControl //分段=======================================================================================================
91
92 -(void)viewDidLoad{
93 [super viewDidLoad];
94
95 self.btn.hidden = YES;
96
97 [self createSegment];
98 }
99
100 -(void)createSegment{
101
102 NSArray *items = @[@"00000", @"1111", @"2222"];
103
104 UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:items];
105
106 segment.frame = CGRectMake(50, 100, 300, 40);
107 segment.backgroundColor = [UIColor magentaColor];
108 segment.tintColor = [UIColor yellowColor];
109 segment.selectedSegmentIndex = 0;
110
111 [segment insertSegmentWithTitle:@"4444" atIndex:1 animated:YES];
112 [segment insertSegmentWithImage:[UIImage imageNamed:@"tab_0"] atIndex:1 animated:YES];
113 //让图片显示原始图片
114 UIImage *img = [[UIImage imageNamed:@"tab_0"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
115
116 [segment insertSegmentWithImage:img atIndex:1 animated:YES];
117
118 [self.view addSubview:segment];
119
120 //添加事件
121 [segment addTarget:self action:@selector(segmentSelected:) forControlEvents:UIControlEventValueChanged];
122
123
124 }
125
126 -(void)segmentSelected:(UISegmentedControl *)segment{
127 NSLog(@"%ld", segment.selectedSegmentIndex);
128 }
129
130
131
132 //UIStepper //步进==================================================================================================
133
134 -(void)viewDidLoad{
135 [super viewDidLoad];
136
137 self.btn.hidden = YES;
138
139 [self createStepper];
140 }
141
142 -(void)createStepper{
143 UIStepper *stepper =[[ UIStepper alloc]initWithFrame:CGRectMake(50, 100, 300, 40)];
144 [self.view addSubview:stepper];
145
146 stepper.tintColor = [UIColor redColor];
147 stepper.backgroundColor = [UIColor greenColor];
148
149 stepper.minimumValue = 0;
150 stepper.maximumValue = 100;
151 stepper.stepValue = 5;
152 stepper.wraps = YES;
153 stepper.autorepeat = YES;
154
155 [stepper addTarget:self action:@selector(steperValueChanged:) forControlEvents:UIControlEventValueChanged];
156 }
157
158 -(void)steperValueChanged:(UIStepper *)stepper{
159 NSLog(@"%f", stepper.value);
160
161
162 }
163
164 //UISwitch //开关======================================================================================================
165
166 -(void)viewDidLoad{
167 [super viewDidLoad];
168
169 self.btn.hidden = YES;
170
171 [self createSwitch];
172 }
173
174 -(void)createSwitch{
175 UISwitch *mySwitch = [[UISwitch alloc]initWithFrame:CGRectMake(50, 100, 200, 40)];
176
177 mySwitch.onTintColor = [UIColor redColor];
178 mySwitch.tintColor = [UIColor greenColor];
179
180 [self.view addSubview:mySwitch];
181
182 [mySwitch addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged];
183 }
184
185 -(void)switchValueChanged:(UISwitch *)mySwitch{
186 if (mySwitch.isOn) {
187 NSLog(@"on");
188 } else{
189 NSLog(@"off");
190 }
191 }
192
193
194 //UITextView //文本================================================================================================
195 -(void)viewDidLoad{
196 [super viewDidLoad];
197
198 self.btn.hidden = YES;
199
200 [self createTextView];
201 }
202
203 -(void)createTextView{
204 UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(50, 100, 200, 100)];
205
206 [self.view addSubview:textView ];
207 }
208
209 //UIAlertController //警报管理===============================================================================
210 - (void)btnClicked {
211
212 UIAlertController *alertCtrl = [UIAlertController alertControllerWithTitle:@"删除" message:@"是否确定要删除该数据" preferredStyle:UIAlertControllerStyleActionSheet];
213 UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil ];
214 UIAlertAction *deleteAction = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
215 NSLog(@"具体的删除数据的代码");
216 }];
217
218 [alertCtrl addAction:cancelAction];
219 [alertCtrl addAction:deleteAction];
220
221 [self presentViewController:alertCtrl animated:YES completion:nil];
222
223 }
224
225
226 - (void)btnClicked3 {
227
228 UIAlertController *alertCtrl = [ UIAlertController alertControllerWithTitle:@"警告" message:@"需要输入用户名和密码" preferredStyle:UIAlertControllerStyleAlert];
229 // 添加文本框
230 [alertCtrl addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
231 // 可以对文本框进行设置
232 textField.placeholder = @"用户名";
233 }];
234
235 [alertCtrl addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
236 textField.placeholder = @"密码";
237 textField.secureTextEntry = YES;
238
239 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pwdTextChanged) name:UITextFieldTextDidChangeNotification object:textField];
240 }];
241
242 // 添加一个动作,就是一个按钮
243 UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"登录" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
244 // 用户点击这个按钮的操作
245 NSLog(@"用户名:%@, 密码:%@", alertCtrl.textFields[0].text , alertCtrl.textFields[1].text );
246 }];
247 action2.enabled = NO;
248 [alertCtrl addAction:action2];
249
250 // 弹出提示信息框
251 [self presentViewController:alertCtrl animated:YES completion:nil];
252
253 }
254
255 -(void)pwdTextChanged{
256 // 取得弹出的UIAlertController对象
257 UIAlertController *alertCtrl = (UIAlertController *) self.presentedViewController;
258 if (alertCtrl) {
259 UIAlertAction *loginAction = alertCtrl.actions.firstObject;
260 loginAction.enabled = YES;
261 }
262
263 }
264
265 - (void)btnClicked2 {
266
267 UIAlertController *alertCtrl = [ UIAlertController alertControllerWithTitle:@"警告" message:@"电量低" preferredStyle:UIAlertControllerStyleAlert];
268
269 UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
270 UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
271 NSLog(@"知道了");
272 }];
273 [alertCtrl addAction:action1];
274 [alertCtrl addAction:action2];
275
276 [self presentViewController:alertCtrl animated:YES completion:nil];
277
278 }

UI-不常用控件 UIActivityIndicatorView、UIProgressView、UISegmentedControl、UIStepper、UISwitch、UITextView、UIAlertController的更多相关文章

  1. [WinForm]WinForm跨线程UI操作常用控件类大全

    前言 在C#开发的WinForm窗体程序开发的时候,经常会使用多线程处理一些比较耗时之类的操作.不过会有一个问题:就是涉及到跨线程操作UI元素. 相信才开始接触的人一定会遇上这个问题. 为了解决这个问 ...

  2. iOS开发-UI (一)常用控件

    从这里开始是UI篇 知识点: 1.常用IOS基本控件 2.UITouch ======================= 常用基本控件 1.UISegmentedControl:分段控制器 1)创建方 ...

  3. iOS开发之七:常用控件--UISlider、UISegmentedControl、UIPageControl的使用

    一.UISlider的使用 其实UISlider在iOS开发中用的似乎不是很多,我们看到的用到的地方多是音乐播放器的音量控制,以及视频播放器中的音量控制. 还是记录一下吧! 1.常用属性 // 设置获 ...

  4. Android开发UI之常用控件的使用

    1.日期选择控件 DatePickerDialog 代码: btnChooseDate=(Button) findViewById(R.id.btnChooseDate); btnChooseDate ...

  5. swift系统学习控件篇:UIProgressView+NSTimer+UIstepper+UIAlertController

    工作之余,学习下swift大法.把自己的学习过程分享一下.当中的布局很乱,就表在意这些细节了.直接上代码: UIProgressView+NSTimer+UIstepper UIStepper UIP ...

  6. 【IOS 开发】基本 UI 控件详解 (UISegmentedControl | UIImageView | UIProgressView | UISlider | UIAlertView )

    转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/50163725 一. 分段控件 (UISegmentedControl) 控件展 ...

  7. UI常用控件

    UICommonlyUsedControls [UI常用控件] 不需要学习多么深入,但是要知道系统提供的有用的控件. 一.UISwitch(开关) 二.UIActivityIndicatorView( ...

  8. 【Android Studio】安卓开发初体验3.1——UI设计之常用控件

    常用控件 首先对xml文件的编辑有三种模式 Code为纯代码 Split是一边代码,一边预览效果图 Designer就是有UI设计界面 TextView 用于在界面上显示一段文本信息 所有控件都可以在 ...

  9. Day3 UI:7种常用控件、4种基本布局

    Android常用控件 TextView <TextView android:id="@+id/text_view" android:layout_width="m ...

随机推荐

  1. 003-spring结合java类调用quartz

    一.利弊 针对001 中设置,不方便程序中动态添加任务,只能使用配置进行配置任务, 适用于已知固定时刻需要执行的任务. 针对002中设置,不方便结合调用spring注入的实体 使用于程序内部新增添的任 ...

  2. 【转】XML的几种读写

    XML文件是一种常用的文件格式,例如WinForm里面的app.config以及Web程序中的web.config文件,还有许多重要的场所都有它的身影.Xml是Internet环境中跨平台的,依赖于内 ...

  3. 解锁CHM文件

    刚在网上下载了CHM格式的文件,打开之后,右侧部分一片空白. 原因:可能是,系统针对来源不明文件的一种保存措施吧 解决方法: 1.选中文件,右键打开属性对话框,在 “常规”选项卡中 勾选 [解除锁定] ...

  4. unity,  在编辑界面中隐藏公开变量

    unity默认声明为public的变量都是在编辑界面可见的,如果要隐藏的话就可以这样做 一种是使用属性 Public float Age { get; set; } 另一种是使用标签 [HideInI ...

  5. linux命令详解之(at)--6/24

    在Linux下,有两个命令可以用来作为计划任务而执行,at:一次性定时任务计划执行crontab :每天定时任务计划执行 以下仅说一下一次性任务计划执行(at)要使用一次性任务计划,linux必须要有 ...

  6. ubuntu+anaconda+python安装各版本tensorflow

    一.安装anaconda 1.去官网下载anaconda linux版本即可 选择合适的版本下载即可 2.安装Aanconda: 打开终端(Ctrl+Alt+t)进入到下载的目录一般在home 下的D ...

  7. JavaWeb 自定义标签库开发传统标签

    自定义标签主要用于移除Jsp页面中的java代码. 移除jsp页面中的java代码,只需要完成两个步骤: 编写一个实现Tag接口的Java类,并覆盖doStartTag方法,把jsp页面中的java代 ...

  8. shell编程学习笔记之正则表达式初识

    1.对单字符的查找: 1.1单字符: ‘X’ $ grep ‘q’ passwd //查找单个字符 1.2 范围字符 [] [^] 1.3 任意字符 . $ grep '[1-9]' passwd / ...

  9. 高亮显示UILabel中的子串

    I. 用户在搜索框中,输入关键字进行检索时,APP对搜索结果进行显示,有以下两种情况: 1. 匹配一次,如检索关键字为人名 这种情况,实现比较容易.写一个UILabel的category, 用rang ...

  10. spring的几个通知(前置、后置、环绕、异常、最终)

    1.没有异常的 2.有异常的 1.被代理类接口Person.java package com.xiaostudy; /** * @desc 被代理类接口 * * @author xiaostudy * ...