iOS-UI-Button按钮自定义图标-图片样式切换

2016-01-18 19:08:00

iOS-UI-Button按钮自定义图标-图片样式切换
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

button.frame = CGRectMake(100, 300, 200, 50);
// 正常状态
[button setBackgroundImage:[UIImage imageNamed:@"register_btn_press@2x.png"] forState:UIControlStateNormal];
// 实现点击切换图片效果 - 高亮状态
[button setBackgroundImage:[UIImage imageNamed:@"register_btn_normal@2x.png"] forState:UIControlStateHighlighted];


[button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];

当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »