UISwitch和UIActivity的使用
- (void)viewDidLoad
{
[super viewDidLoad];
//创建一个开关控件,苹果给它固定的size(79*27),frame更改size无效
//继承于UIControl 为事件驱动型控件
UISwitch *st = [[UISwitch alloc] initWithFrame:CGRectMake(10,10,100,50)];
//on 属性,控制开关的开闭(YES 开)
st.on =YES;
//事件驱动型,通过event事件,通知target对象执行action中的方法 (函数)
//UIControlEventValueChanged 当控件的值发生变化时所对应的事件
[st addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:st];
self.view.backgroundColor = [UIColor blackColor];
//加载等待提示控件,初始化的时候,设定风格样式
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];//控件的size固定
//设置中心点为view的中心点
activityView.center = self.view.center;
activityView.tag = 100;
[self.view addSubview:activityView];
//让提示控件转动
[activityView startAnimating];
//[activityView stopAnimating];
}
- (void)switchValueChanged:(UISwitch *)st{
UIActivityIndicatorView *activityView = (UIActivityIndicatorView *)[self.view viewWithTag:100];
if (st.on) {
NSLog(@"开!");
[activityView startAnimating];
}else{
NSLog(@"关!");
//停止转动
[activityView stopAnimating];
}
}
UISwitch和UIActivity的使用的更多相关文章
- UI2_UISwitch与UIActivity
// // ViewController.m // UI2_UISwitch与UIActivity // // Created by zhangxueming on 15/7/7. // Copyri ...
- UI第十节——UISwitch
- (void)viewDidLoad { [super viewDidLoad]; // 实例化UISwitch,固定大小 UISwitch *swc = [[UISwit ...
- 使用subclass UIActivity的方案来分享图片
IOS6开始, 系统提供了UIActivityViewController, 对图片,文字,url进行相关的操作. 对于缺乏UI设计师的开发来说, 使用它进行轻量级的分享是很好的选择. 最大的缺点是自 ...
- UISwitch
UISwitch *noticeSwtich = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 51, 31)]; // noticeSwtich. ...
- UI中一些不常用的控件UIActivityIndicatorView、UIProgressView、UISegmentedControl、UIStepper、UISwitch、UITextView、UIAlertController
//UIActivityIndicatorView //小菊花,加载 #import "ActivityIndicatorVC.h" @interface ActivityIndi ...
- UILabel UISwitch UISegmentedControl UIAlertView
基础小控件 /***************************************UIlabel*************************************/ UILabel ...
- ios7 上 UIActivity 用的image
在ios8 上UIActivityCategoryShare类型的UIActivity的图标支持彩色图片了,但是在ios7上不行,ios8上的 UIActivityCategoryAction类型也不 ...
- UISwitch控件的使用
UISwitch控件的作用是提供一个开关给用户,用户可以选择打开或者关闭. UISwitch的基本属性包括: 1.onTintColor:打开状态下的背景颜色 2.thumbTintColor:滑块的 ...
- UIImageView、UISlider、UISwitch、UIStepper、UISegmentControl
UIImageView——图像视图 作用:专门用来显示图片的控件 . 设置图像 [self.imageView setImage:[UIImage imageNamed:@"abc.png& ...
随机推荐
- 每日Scrum--No.5
Yesterday:学习并编写代码 Today:组织小组开一次阶段性的总结会议:讨论需求分析中存在的问题:继续学习和编写代码:总结前阶段代码出现的问题 Problem:编程要注意很多的特殊情况,程序成 ...
- INFORMATICA 的部署实施 MTP&MTS
软件开发的一般都有三个环境,开发环境,用户接受度测试环境,生产环境.我最近实施了从开发环境到生产环境的部署工作,在此跟大家分享一下. 大概步骤如下: 1 备份生产环境INFORMATICA 知识库 ...
- EF+MVC+cod First项目性能优化总结
1.EF:this.Configuration.UseDatabaseNullSemantics = true; //关闭数据库null比较行为 2.实体必填字段要加:[Required]属性,可定长 ...
- sql server中游标
参考:http://blog.csdn.net/luminji/article/details/5130004 利用SQL Server游标修改数据库中的数据 SQL Server中的UPDATE语句 ...
- Effective Java 44 Write doc comments for all exposed API elements
Principle You must precede every exported class, interface, constructor, method, and field declarati ...
- Effective Java 59 Avoid unnecessary use of checked exceptions
The burden is justified if the exceptional condition cannot be prevented by proper use of the API an ...
- 完全卸载VS2005或VS2008的步骤
手动卸载步骤: Visual Studio Express Editions 进入控制面板,运行添加或删除程序 卸载 "MSDN Library for Visual Studio 200 ...
- TOMCAT报错:HTTP Status 404 -
构建struts2工程师,tomcat报错: HTTP Status 404 - type Status report message description The requested resour ...
- 叶金荣:MySQL通用优化技巧
转自:http://mp.weixin.qq.com/s?__biz=MjM5NDE0MjI4MA==&mid=208777870&idx=1&sn=6efddd6283e4d ...
- [部署]CentOS安装apache
环境 虚拟机:VMWare10.0.1 build-1379776 操作系统:CentOS7 64位 步骤 1.使用yum安装 yum install httpd httpd-devel 2.启动 a ...