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

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

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


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

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

标签: none

添加新评论