UIButton详解
// ----------------------------------UIButton------------------------------
// UIButtonTypeSystem 点击文字会有效果,变色 UIButtonTypeCustom 无点击效果
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(200, 100, 200, 80);
[button setTitle:@"click me" forState:UIControlStateNormal];
button.backgroundColor = [UIColor blueColor];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
// 字体大小
button.titleLabel.font = [UIFont systemFontOfSize: 20.0];
// button.font = [UIFont systemFontOfSize:20]; 废弃
//边框
button.layer.borderWidth = 3;
button.layer.borderColor = [UIColor grayColor].CGColor;
// 设置圆角
[button.layer setMasksToBounds:YES];
[button.layer setCornerRadius:20.0];
// 按下会有发光的效果
button.showsTouchWhenHighlighted = YES;
// 文字居左
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
// 文字居顶
button.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
// 文字内边距
button.contentEdgeInsets = UIEdgeInsetsMake(10, 10, 0, 0);
[button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
UIButton详解的更多相关文章
- UI第二节——UIButton详解
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc ...
- UIButton 详解
1)创建 UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 风格有如下 typedef enum { UIButt ...
- IOS开发学习笔记(2)-----UIButton 详解
1. [代码][C/C++]代码 //这里创建一个圆角矩形的按钮 UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRou ...
- 【iOS 开发】基本 UI 控件详解 (UIButton | UITextField | UITextView | UISwitch)
博客地址 : http://blog.csdn.net/shulianghan/article/details/50051499 ; 一. UI 控件简介 1. UI 控件分类 UI 控件分类 : 活 ...
- 【iOS自定义键盘及键盘切换】详解
[iOS自定义键盘]详解 实现效果展示: 一.实现的协议方法代码 #import <UIKit/UIKit.h> //创建自定义键盘协议 @protocol XFG_KeyBoardDel ...
- iOS中 HTTP/Socket/TCP/IP通信协议详解
// OSI(开放式系统互联), 由ISO(国际化标准组织)制定 // 1. 应用层 // 2. 表示层 // 3. 会话层 // 4. 传输层 // 5. 网络层 // 6. 数据链接层 // 7. ...
- AFNetworking 与 UIKit+AFNetworking 详解
资料来源 : http://github.ibireme.com/github/list/ios GitHub : 链接地址 简介 : A delightful iOS and OS X networ ...
- UI第六节——UINavigationController 详解
1. UINavigationController 是一个容器类.里面盛放的是UIViewController. 容器的意思是,如果你不放入UIViewController,里面就是空的,什么也没有. ...
- UIWebView用法详解及代码分享
今天我们来详细UIWebView用法.UIWebView是iOS内置的浏览器控件,可以浏览网页.打开文档等 能够加载html/htm.pdf.docx.txt等格式的文件. 用UIWebView我们就 ...
随机推荐
- NSDate 获取明天、后天的日期
NSDate * senddate=[NSDate date]; NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIde ...
- 使用 PHP 限制下载速度
使用 PHP 限制下载速度 [来源] 达内 [编辑] 达内 [时间]2012-12-12 经常遇到一个问题,那就是有人再办公室下载东西,影响大家上网.办公.同样的问题,要是出现在了服务器上面 ...
- 纸牌project
用range[0,8)的列表表示牌,这些数字要出现两次.我们建议你通过连接两个range[0,8)的列表来创建这个list.利用Docs来安排列表串联操作 写一个draw handler啥样的draw ...
- garbage collection - 垃圾收集
Professional.JavaScript.for.Web.Developers.3rd.Edition.Jan.2012 JavaScript is a garbage-collected la ...
- Java IO包装流如何关闭?
问题: (1)JAVA的IO流使用了装饰模式,关闭最外面的流的时候会自动调用被包装的流的close()方吗? (2)如果按顺序关闭流,是从内层流到外层流关闭还是从外层到内存关闭? 问题(1)解释: ...
- Java:按值传递还是按引用传递详细解说
前天在做系统的时候被Java中参数传递问题卡了一下,回头查阅了相关的资料,对参数传递问题有了新的了解和掌握,但是有个问题感觉还是很模糊,就是Java中到底是否只存在值传递,因为在查阅资料时,经常看到有 ...
- 批处理快速创建wifi
为什么要用cmd这种古老的东西创建wifi呢,电脑管家.360安全卫士都有这种插件,一键开启关闭,多方便啊! 开始用的也是电脑管家的免费wifi插件,但是我越来越不能忍它极慢的启动关闭过程,每一次看着 ...
- Jsoncpp 数组的使用
JsonCpp 是一个C++用来处理JSON 数据的开发包.下面讲一下怎么使用JsonCpp来序列化和反序列化Json对象,以实际代码为例子. 反序列化Json对象 比如一个Json对象的字符串序列如 ...
- day11
JSP入门 1 JSP概述 1.1 什么是JSP JSP(Java Server Pages)是JavaWeb服务器端的动态资源.它与html页面的作用是相同的,显示数据和获取数据. 1.2 ...
- VC更换图标文件
步骤 1. 删除图标 2. 在VC中移除图标 3. 用新图标替换原来图标 4. 添加图标到VC 5. 重新编译 参考文档 http://www.cnblogs.com/BloodAndBone/arc ...