我知道如何使用色调
更改UIActionSheet的字体颜色- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
[[UIView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[[ColorUtil alloc] colorWithHexString:@"25A559"]];
}
如何将其应用于商品。例如。第一项为红色,第二项为绿色。
答案 0 :(得分:0)
检查我的答案
#pragma mark - changeImage
- (IBAction)myActionSheet:(id)sender
{
UIActionSheet *actionSheet=[[UIActionSheet alloc] initWithTitle : @"Choose Image" delegate : self cancelButtonTitle :@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Gallery",@"Camera",nil];
actionSheet.tag = 1000;
[actionSheet showInView :self.view];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
UIAlertController *alertController = [actionSheet valueForKey:@"_alertController"];
if ([alertController isKindOfClass:[UIAlertController class]])
{
alertController.view.tintColor = [UIColor redColor];// set your color here
}
}
}
对于iOS版本低于8.0,使用相同的旧代码UIActionSheet委托方法:
#pragma mark - actionsheet delgates
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
for (UIView *subview in actionSheet.subviews) {
if ([subview isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)subview;
[button setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; // set your color
}
}
}