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

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];

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

标签: none

添加新评论

Title - Artist
0:00