Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
10. Đối với nút thứ hai, mở thanh tra thuộc tính Buttons. Đảm bảo các cảm ứng cho Đánh dấu là kiểm tra (hình 12-4). 11. Chú ý thả xuống (Hình 12-5). Ở đây bạn chọn nhà nước của nút và liên quan lĩnh vực của giá trị sẽ chỉ áp dụng đối với nhà nước đó. | Chapter 12 Controls Part One 273 Figure 12-4 Ensure the Shows Touch on Highlight is checked. 10. For the second button open the inspector to Buttons Attributes. Ensure the Shows Touch on Highlight is checked Figure 12-4 . 11. Notice the drop-down Figure 12-5 . Here you select the button s state and the related field s values will only apply to that state. Ensure Default State Configuration is selected. 12. Change Background to butbackgray.png and change Image to power.png. 13. Select Highlighted State Configuration and change Background to butbackbluegray.png and Image to power.png. continued 274 iPhone SDK Programming A Beginner s Guide Figure 12-5 Selecting a button s state 14. Select Disabled State Configuration and change Background to butbackgraydisabled.png and Image to powerdisabled.png. 15. For the third button ensure Default State Configuration is selected and add the text Shock to Title. Select the butbackgray.png for Background. 16. Select Highlighted State Configuration and add the text Shocking to Title. Select butbackbluegray.png as the Background. Note do not make any changes to the Disable setting. 17. Resize the buttons as necessary so they appear nice. 18. Click Build And Go to run the application. Chapter 12 Controls Part One 275 Listing 12-1 ButtonsBackgroundViewController.h import UIKit UIKit.h interface ButtonsBackgroundViewController UlViewController IBOutlet UIButton clearButton IBOutlet UIButton smallButton property nonatomic retain IBOutlet UIButton clearButton property nonatomic retain IBOutlet UIButton smallButton - IBAction disableBut id sender end Listing 12-2 ButtonsBackgroundViewController.m import ButtonsBackgroundViewController.h implementation ButtonsBackgroundViewController synthesize clearButton synthesize smallButton - IBAction disableBut id sender if clearButton.enabled YES clearButton.enabled NO smallButton.enabled NO UIButton sender setTitle Enable forState UIControlStateNormal else clearButton.enabled YES .