这件事把我难住了.
是否有可能在iPhone的Cocoa中更改UIButton的背景色.
[random setBackgroundColor:[UIColor blueColor]];
[random.titleLabel setBackgroundColor:[UIColor blueColor]];
这件事把我难住了.
是否有可能在iPhone的Cocoa中更改UIButton的背景色.
[random setBackgroundColor:[UIColor blueColor]];
[random.titleLabel setBackgroundColor:[UIColor blueColor]];
这可以通过制作副本以编程方式完成:
loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
[loginButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
loginButton.backgroundColor = [UIColor whiteColor];
loginButton.layer.borderColor = [UIColor blackColor].CGColor;
loginButton.layer.borderWidth = 0.5f;
loginButton.layer.cornerRadius = 10.0f;
编辑:当然,你得#import <QuartzCore/QuartzCore.h>
美元
编辑:对于所有的新读者,你也应该考虑增加一些选项作为"另一种可能性".供你考虑.
As this is an old answer, I strongly recommend reading comments for troubleshooting