創建了一個帶有梯度層的按鈕梯度層:的UIButton與不突出
//MyGradient creates and returns gradient layers
CAGradientLayer *gradient = [MyGradient blueGradient];
//MyButton is a subclassed UIButton which adds some attributes
MyButton *testButton = [MyButton buttonWithType:UIButtonTypeCustom];
testButton.frame = CGRectMake(10, 10, 150, 50);
[testButton addTarget:self action:@selector(testButton:) forControlEvents:UIControlEventTouchUpInside];
[gradient setFrame:testButton.bounds];
testButton.clipsToBounds = YES;
[testButton.layer insertSublayer:gradient atIndex:0];
[self.view addSubview:testButton];
我怎樣才能獲得圖像時,按下突出?我已經找到了幾個子類化UIButton並覆蓋drawRect:方法的示例代碼。有沒有更簡單的方法讓按鈕突出顯示?
補充一點,使用'UIGraphicsBeginImageContext'和朋友生成圖像是非常簡單的。 – benzado