UIKit---UIButton详解
来源:互联网 发布:开票软件赋码 编辑:程序博客网 时间:2024/05/01 21:17
UIbutton作为简单且频繁被使用的控件,其地位在整个app开发中不可小视。在IB中使用button相对来说很简单,很容易上手,但在多视图开发中button通常会被即时生成,并设置其属性和功能,即通过代码生成。如下是我对button的理解。
//创建圆角button
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];
//指定button的位置和大小
button.frame = CGRectMake(10, 10, 75, 75);
//给button设置标签,用来辨别点击的是哪个button,常用在委托方法中。
button.tag = 0;
//定义按钮标题
[button setTitle:@"Button Title" forState:UIControlStateNormal];
//定义按钮标题字体格式
[button.titleLabel setFont:[UIFont boldSystemFontOfSize:20]];
//给button添加委托方法,即点击触发的事件。
[button addTarget:selfaction:@selector(touchButton1:) forControlEvents :UIControl EventTouchUp Inside];
//给button添加图片
[button setImage:[UIImageimageNamed:@"blue_bg(2).png"] forState:UIControlStateNormal];
//将button加入视图当中
[view addSubview:button];
使用技巧:
button不仅可以用来加载图片还可以加载label来实现特定文本的显示。
[button addSubview:label];
- UIKit---UIButton详解
- UIKIT详解之UIButton全面解析
- UIKit之浅析UIButton
- UIKit--UIButton的简单应用
- UIKit框架-04.UIButton
- UIKit详解
- UIKit详解
- UIKit详解
- UIKit框架-基础控件Swift版本: 2.UIButton方法/属性详解
- IOS学习笔记---UIKit之UIButton
- UIKit框架(UIButton父类等)
- UIKit框架之—— UIButton
- Objective-C:: UIKit: 视图控制器、UILabel、UIButton
- UIButton 详解
- UIButton 详解
- UIButton 详解
- UIButton 详解
- UIButton详解
- 伪类和为元素
- ImportError: No module named feedparser
- 支付宝充退、充退转账
- 中断服务子程序
- Python Show-Me-the-Code 第 0002 题 MySQL操作
- UIKit---UIButton详解
- 重定位PC相对引用(PC-relative reference relocation)
- SMARTFORMS(小计、合计)
- bzoj 3675: [Apio2014]序列分割
- 7-2通信系统中为什么要进行调制和解调?调制的分类方法有哪些?
- android根据屏幕尺寸区分设备类型,phone或者pad
- Gemcom.Minex.v6.1.1 1CD
- private,空,protected,public 权限
- 看数据结构写代码(46) 关键路径