我试图更改我的UIActionSheet
中按钮的颜色。问题(一个非常奇怪的问题)是,如果设备的方向是横向,按钮颜色不会改变! 一些截图: Objective C UIActionSheet自定义按钮颜色
我想不通为什么!
下面的代码:
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
[actionSheet.subviews enumerateObjectsUsingBlock:^(id _currentView, NSUInteger idx, BOOL *stop) {
if ([_currentView isKindOfClass:[UIButton class]]) {
[((UIButton *)_currentView).titleLabel setTextColor:[[MSAppDelegate sharedInstance] defaultColor]];
}
}];
/*
for (UIView *subview in actionSheet.subviews) {
if ([subview isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)subview;
[button setTitleColor:[[MSAppDelegate sharedInstance] defaultColor] forState:UIControlStateNormal];
[button setTitleColor:[[MSAppDelegate sharedInstance] defaultColor] forState:UIControlStateSelected];
}
if ([subview isKindOfClass:[UILabel class]]) {
UILabel *label = (UILabel *)subview;
label.textColor = [[MSAppDelegate sharedInstance] defaultColor];
}
}
*/
}
我也尝试了注释代码,在人像都工作,但不是在风景!
顺便说一句无论是在景观和肖像的代码执行!
如果你想看到所有的代码,这里的link
预先感谢您!
这将停止工作作为很快你必须翻阅你的选项。那时所有的选项都会在UItableView中显示出来。 –
你错了,它应该是这样!这不是问题! –
显然它没有,要么你不必问如何解决它。在Landscape中,ActionSheet在一个TableView中以不是纵向显示其按钮。所以你的方法在肖像,但不是在景观。 –