![](/img/trans.png)
[英]How to set different different text colour for each cell in UICollectionView?
[英]How do you set a different font colour for each item in a UIActionSheet
我知道如何使用色调更改UIActionSheet的字体颜色
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
[[UIView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[[ColorUtil alloc] colorWithHexString:@"25A559"]];
}
如何将其应用于项目。 例如。 第一项为红色,第二项为绿色。
检查我的答案
#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
}
}
}
对于小于8.0的iOS版本,使用相同的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
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.