[英]Customized clickable object(button) IOS - Objective C (Xcode5)
我需要創建一種可點擊的對象,可以是一個按鈕。 圖形應為矩形,中間帶有文本。 矩形應該像按鈕一樣可單擊。 它的拐角處應該有四個標簽,它們應該能夠容納整數。 單擊這些“標簽”時,我需要執行另一項操作,例如再次單擊按鈕。
我到底該如何開始呢?
用五個按鈕制作一個UIView子類(如果可以點擊它們,它們應該是按鈕而不是標簽)
@property (nonatomic, weak) IBOutlet UIButton *middleButton;
@property (nonatomic, weak) IBOutlet UIButton *topLeftButton;
@property (nonatomic, weak) IBOutlet UIButton *topRightButton;
@property (nonatomic, weak) IBOutlet UIButton *bottomLeftButton;
@property (nonatomic, weak) IBOutlet UIButton *bottomRightButton;
您還需要連接IBAction來告知何時點擊按鈕。
[self.middleButton addTarget:self action:@selector(middleButtonTapped) forControlEvents:UIControlEventTouchUpInside];
- (void)middleButtonTapped
{
//This method is called when the middle button is tapped
}
您也可以創建IBAction並將按鈕掛在情節提要/ xib中
- (IBAction)middleButtonTapped
{
//This method is called when the middle button is tapped
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.