UI控件(UIButton)
2024-08-31 04:36:29
@implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// UIButtonTypeCustom = 0, 自定义风格
// UIButtonTypeRoundedRect, 圆角矩形
// UIButtonTypeDetailDisclosure, 蓝色小箭头按钮
// UIButtonTypeInfoLight, 亮色感叹号
// UIButtonTypeInfoDark, 暗色感叹号
// UIButtonTypeContactAdd, 十字加号按钮
button_ = [UIButton buttonWithType:UIButtonTypeRoundedRect]; //[button setTitle:@"注册" forState:UIControlStateNormal]; UIImage *normalImage = [UIImage imageNamed:@"icon_u1.png"];
UIImage *pressedImage= [UIImage imageNamed:@"icon_u10.png"]; // UIControlStateNormal 正常状态
// UIControlStateHighlighted 高亮状态
// UIControlStateDisabled 禁用状态
// UIControlStateSelected 选中状态
[button_ setBackgroundImage:normalImage forState:UIControlStateNormal];
[button_ setBackgroundImage:pressedImage forState:UIControlStateDisabled]; [button_ setFrame: CGRectMake(, , , )]; // UIControlEventTouchDown 单点触摸按下
// UIControlEventTouchDownRepeat 多点触摸按下,多个手指
// UIControlEventTouchUpInside 控件触摸的抬起事件
// UIControlEventAlltouchEvents 所有触摸事件
[button_ addTarget:self action:@selector(doClick) forControlEvents:UIControlEventTouchDown]; [self.view addSubview:button_];
} -(void)doClick{
NSLog(@"%s", __FUNCTION__);
//禁止该按钮点击
button_.enabled = NO;
} @end
最新文章
- HTML常用标签总结
- 【OpenJudge 1665】完美覆盖
- Mock之easymock, powermock, and mockito
- CodeForces 353B Two Heaps
- Android ListView简单实用
- 2、JavaScript常用互动方法
- 编译器错误消息: CS0234: 命名空间“Purple”中不存在类型或命名空间名称“Model”(是否缺少程序集引用?)
- linux c数据库备份第四版
- BestCoder Round #38
- newinstance()和new有什么区别?(转)
- Ios8之后, 定位的delegate不能触发的问题
- 使用js代码将html导出为Excel
- wf 2017A
- 【转】SQL数据库日志文件收缩
- python文件流
- 线程变量---ThreadLocal类
- kafka 备忘
- 用secureCRT操作ubuntu终端
- linux RPM包安装、更新、删除等操作命令简明总结, 如何查看yum安装的软件路径 ?
- map正序、逆序排序