我有一個應用程序的底部,我創建使用UIButton庫,GradientButton(在這裏找到:http://code.google.com/p/iphonegradientbuttons/)的按鈕。如何讓我的GradientButton在我的iPhone應用程序中重繪?
我可以創建按鈕罰款,但我可以不爲世人弄清楚如何改變創建按鈕的顏色漸變我設置的顏色一次之後...
我想,作爲一個例子,
- (IBAction)buttonPressed:(id)sender{
NSLog(@"buttonPressed;changing style");
[checkInCheckOutButton useAlertStyle];//build-in method in gradientbutton that sets colour
[checkInCheckOutButton setNeedsDisplay];//added this when first didn't work.
}
我失去了一些東西在這裏:改變我的按鈕的各種技巧的ActionListener梯度,例如(我是第一次設置它在viewDidLoad中)?如果我改變任何其他內置組件,比如說一個普通按鈕的文本和/或背景,所有的都可以正常工作。
如果有什麼東西我沒有收到關於對象在目標C粉刷,我所有的耳朵...
編輯:建議之後,我嘗試添加一些代碼來改變顏色陣列按鈕。不幸的是,這也沒有工作:
- (IBAction)buttonPressed:(id)sender{
NSLog(@"buttonPressed;changing style");
self.checkInCheckOutButton.normalGradientColors = [NSArray arrayWithObjects:[UIColor redColor], [UIColor blueColor], nil];
self.checkInCheckOutButton.highlightGradientColors = [NSArray arrayWithObjects:[UIColor greenColor], [UIColor whiteColor], nil];
[self.checkInCheckOutButton setNeedsDisplay];//tried with and without
Whee,好東西。謝謝! – Mathias