UIAlertController的NSTextAlignmentLeft

sou*_*ned 5 ios uialertcontroller

有没有人能够找到一种方法来设置文本对齐方式UIAlertController.更具体地说,动作表格式?

我正在使用此方法将图片(图标)添加到操作:

UIImage *qsimage = [UIImage imageNamed:@"snapshot.png"];
[snapshot setValue:qsimage forKey:@"image"];
//where 'snapshot' is a UIAlertAction
Run Code Online (Sandbox Code Playgroud)

这很好用,不用担心,但是当向控制器添加多个动作时,所有文本都居中但图像左对齐会产生尴尬的UI体验.

我试图像苹果公司在即将推出的iOS 8.4音乐应用程序中所做的那样:

PIC1

思考?我错过了一些简单的事吗?

编辑

在做了一些调试之后,我意识到Alert Actions在UICollectionView中.我可以成功更改所有按钮的颜色,但不能根据对齐方式更改动作的标签.以下是我访问它们的方式:

 [[UICollectionView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[UIColor blueColor]];
Run Code Online (Sandbox Code Playgroud)

我也尝试使用setTitleTextAttributes对NSDictionary对象和键的操作没有成功.有任何想法吗?

Iva*_*van 3

这是经过测试和工作的 - 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
Run Code Online (Sandbox Code Playgroud)

用法:

UILabel * appearanceLabel = [UILabel appearanceWhenContainedIn:UIAlertController.class, nil];
[appearanceLabel setAppearanceAlignment:NSTextAlignmentLeft];
Run Code Online (Sandbox Code Playgroud)