Jon*_*onB 15
您可以为按下按钮的不同状态定义图像.这是一个简短的例子:
UIButton *submitbutton = [UIButton buttonWithType:UIButtonTypeCustom];
// position in the parent view and set the size of the button
submitbutton.frame = CGRectMake(165, 20, 149, 39);
[submitbutton setTitle:@"Submit Booking" forState:UIControlStateNormal];
// Add image to button for normal state
UIImage * btnImage1 = [UIImage imageNamed:@"SubmitBooking-normal.png"];
[submitbutton setImage:btnImage1 forState:UIControlStateNormal];
// Add image to button for pressed state
UIImage * btnImage2 = [UIImage imageNamed:@"SubmitBooking-pressed.png"];
[submitbutton setImage:btnImage2 forState:UIControlStateHighlighted];
// add targets and actions
[submitbutton addTarget:self action:@selector(submitBookingButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
// add to a some parent view.
[someview addSubview:submitbutton];
Run Code Online (Sandbox Code Playgroud)
您可能还想要自定义其他内容.您可以在此处详细了解这些选项
| 归档时间: |
|
| 查看次数: |
20114 次 |
| 最近记录: |