UIActionSheet修改文字顏色
UIActionSheet是常用的控制元件之一,但往往需要再原來的基礎上修改一些小細節,這裡主要講解怎麼在iOS7以下和以上的處理方法。
-(void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
SEL selector = NSSelectorFromString(@"_alertController");
if ([actionSheet respondsToSelector:selector])//ios8 以後採用UIAlertController來代替uiactionsheet和UIAlertView
{
UIAlertController *alertController = [actionSheet valueForKey:@"_alertController"];
if ([alertController isKindOfClass:[UIAlertControllerclass]])
{
alertController.view.tintColor = [UIColorblackColor];
}
}
else//ios7 之前採用這樣的方式
{
for(
UIView * subView
{
if( [subView isKindOfClass:[UIButtonclass]] )
{
UIButton * btn = (UIButton*)subView;
[btn setTitleColor:[UIColorblackColor] forState:UIControlStateNormal];
}
}
}
}