是否有人能够找到一种方法来设置UIAlertController的文本对齐。更具体地说,行动单的样式?
我使用此方法向操作添加图片(图标):
UIImage *qsimage = [UIImage imageNamed:@"snapshot.png"];
[snapshot setValue:qsimage forKey:@"image"];
//where 'snapshot' is a UIAlertAction这很好,不用担心,但是当向控制器添加多个操作时,所有的文本都是居中的,但是图像是对齐的,这就创造了一种尴尬的UI体验。
我正试图模仿苹果公司即将推出的音乐应用程序iOS 8.4:

有什么想法?我错过了一些简单的东西吗?
编辑
在进行了一些调试之后,我意识到警报操作在一个UICollectionView中。我可以成功地更改所有按钮的颜色,但不能在对齐方面更改操作的标签。下面是我访问它们的方式:
[[UICollectionView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[UIColor blueColor]];我还尝试在带有setTitleTextAttributes对象和键的操作中使用NSDictionary,但没有成功。有什么想法吗?
发布于 2015-07-14 09:05:46
这是经过测试和工作的- UILabel+Appearance.h:
@interface UILabel (FontAppearance)
@property (nonatomic, assign) NSTextAlignment appearanceAlignment UI_APPEARANCE_SELECTOR;
@end
@implementation UILabel (FontAppearance)
-(void)setAppearanceAlignment:(NSTextAlignment)alignment {
[self setTextAlignment:alignment];
}
-(NSTextAlignment)appearanceAlignment {
return self.textAlignment;
}
@end用法:
UILabel * appearanceLabel = [UILabel appearanceWhenContainedIn:UIAlertController.class, nil];
[appearanceLabel setAppearanceAlignment:NSTextAlignmentLeft];https://stackoverflow.com/questions/29666192
复制相似问题