Iphone 绘制自定义按钮
我正在绘制一个自定义按钮:Iphone 绘制自定义按钮,iphone,objective-c,cocoa-touch,uibutton,Iphone,Objective C,Cocoa Touch,Uibutton,我正在绘制一个自定义按钮: UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom]; myButton.frame = CGRectMake(10,10,44,70); [myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [myButton setTitle:@"Order" forState:UIControlStat
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
myButton.frame = CGRectMake(10,10,44,70);
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[myButton setTitle:@"Order" forState:UIControlStateNormal];
当我点击按钮时,背景颜色没有改变。我是否需要为正常状态和选定状态使用不同的图像?这里的诀窍是什么?是的,您需要为不同的状态使用不同的图像:
[myButton setBackgroundImage:someUIImageRef forState:UIControlStateNormal];
[myButton setBackgroundImage:someOtherUIImageRef forState:UIControlStateHighlighted];
对。
因为您使用的是自定义按钮,所以需要手动描述每个状态,否则它们将看起来像正常状态