NSTextAlignmentLeft for UIAlertController

Has anyone been able to find a way to set the text alignment to UIAlertController. In particular, the style of action?

I use this method to add images (icons) to actions:

UIImage *qsimage = [UIImage imageNamed:@"snapshot.png"];
[snapshot setValue:qsimage forKey:@"image"];
//where 'snapshot' is a UIAlertAction

This works fine, no worries, but when you add a few actions to the controller, all the text is centered, but the images are aligned to the left, creating an uncomfortable interface.

I'm trying to be like what Apple did in the near future for iOS 8.4 for its music app:

pic1

Thoughts? Am I missing something simple?

change

After doing some debugging, I realized that the alert actions are in the UICollectionView. I can successfully change the colors of all buttons, but I can’t change the action labels in terms of alignment. Here's how I turned to them:

 [[UICollectionView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[UIColor blueColor]];

setTitleTextAttributes NSDictionary . ?

+4
1

- 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];
+2

All Articles