0
按鈕是不是UIButton
時的α,它是UIControl
怎麼給你使圖像改變它觸及
一個子類,當用戶點擊我的UIControl
,我想改變阿爾法,使用戶有一定的視覺反饋,它被按下。然後在rayWenderlich.com發佈
UIImageView *mask =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 58, 58)];
mask.image =[UIImage imageNamed:@"centerButton.png"];
mask.center = self.center;
mask.center = CGPointMake(mask.center.x, mask.center.y+3);
[self addSubview:mask];
中間按鍵使用a tutorial創建學習有關創建自定義的控件時,再次進行更改。
我被卡住了。我無法弄清楚如何引用中心圖像。
這裏是我的.h類
@interface OOTRotaryWheel : UIControl
@property (weak) id <OOTRotaryProtocol> delegate;
@property (nonatomic, strong) UIView *container;
@property int numberOfSections;
@property CGAffineTransform startTransform;
@property (nonatomic, strong) NSMutableArray *sectors;
@property int currentSector;
@property (nonatomic, retain) UIImageView *mask;
- (id) initWithFrame:(CGRect)frame andDelegate:(id)del withSections:(int)sectionsNumber;
- (void)rotate;
- (void) buildSectorsEven;
- (void) buildSectorsOdd;
@end
那麼,如何檢測觸摸向下的UIImageView和觸摸起來?並使它更像一個按鈕(所以,當我可以加載另一個廈門國際銀行或某事)
我認爲你的意思是「touchUpInside」而不是「buttonUpInside」。 – pasawaya
是的,但Xib是空的。這些控件是在代碼中創建的。 (請參閱網站,因爲我遵循教程)。我在屬性 –
中爲Mask創建了一個變量。如果mask變量不是全局變量,則將其變爲全局變量,因爲這將是最有效的方法。否則,你會使用這個酷的高級for循環,但它不是那麼高效,嘗試UITouches方法,它應該工作,如果沒有,我會告訴你另外兩個選項。 – Comradsky