码迷,mamicode.com
首页 > 移动开发 > 详细

iOS UIButton使用

时间:2015-06-20 15:49:51      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:

创建:

UIButton *hongbao = [UIButton buttonWithType:UIButtonTypeCustom];

Custom:自定义按钮

System:对图片貌似有影响,显示的不是正常的图片


调整位置:这俩函数调了半天:注意偏移是指原有的位置,并不是距离按钮边框的距离,可以设负值,即向相反方向移动

[hongbao setImageEdgeInsets:UIEdgeInsetsMake(-15, 5, 0, 0)];
[hongbao setTitleEdgeInsets:UIEdgeInsetsMake(50, -40, 0, 0)];

参数意义:参数一二三四分别代表向右下左上移动的像素,注意是在原有基础上。

比如UIEdgeInsetsMake(10,0,10,0);就是没有移动


设置文字大小及颜色:

hongbao.titleLabel.font = [UIFont systemFontOfSize: 14.0];
[hongbao setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];


事件响应:

[hongbao addTarget:self action:@selector(clickedHongBao) forControlEvents:UIControlEventTouchDown];



iOS UIButton使用

标签:

原文地址:http://my.oschina.net/littleDog/blog/469115

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!