我一直在使用以下代码来更改我添加的项目的文本颜色UIActionSheet.:
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
for (UIView *subview in actionSheet.subviews) {
if ([subview isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)subview;
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
}
}
}
Run Code Online (Sandbox Code Playgroud)
它工作正常iOS7,但在iOS8上面的代码中不会更改项目的文本颜色.
现在的问题是如何改变我在新增项目的文本颜色UIActionSheet使用iOS8?
附加信息:
我添加了断点,以查看上述代码中的以下行是否被执行:
UIButton *button = (UIButton *)subview;
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
这些行不会被执行.所以,if([subview isKindOfClass:[UIButton class]])总是false适用于所有项目actionSheet.subviews.所以我认为观点层次
UIActionSheet改变了.
我想改变image of的buttons的UIActionSheet,我有images每个button了,我希望每个button显示image我想要的.我在网上搜索了我找到了很多答案,但是他们没有用.
这是初始化的 UIActionSheet
-(IBAction)showActionSheet:(id)sender {
UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"title" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:nil otherButtonTitles:@"Other Button 1", @"Other Button 2", nil];
popupQuery.actionSheetStyle = UIActionSheetStyleDefault;
[popupQuery showInView:self.view];
[popupQuery release];
}
Run Code Online (Sandbox Code Playgroud)