gpt4 book ai didi

ios - UIAlertController 的 NSTextAlignmentLeft

转载 作者:可可西里 更新时间:2023-11-01 04:45:53 28 4
gpt4 key购买 nike

有没有人能够找到一种方法来设置 UIAlertController 的文本对齐方式。更具体地说, Action 表样式?

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

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

这工作得很好,不用担心,但是当向 Controller 添加多个操作时,所有文本都居中,但图像左对齐,从而造成尴尬的 UI 体验。

我正在尝试模仿 Apple 在即将成为 iOS 8.4 的音乐应用程序中所做的事情:

pic1

想法?我错过了一些简单的东西吗?

编辑

在进行一些调试后,我意识到警报操作位于 UICollectionView 中。我可以成功更改所有按钮的颜色,但无法根据对齐方式更改操作的标签。以下是我访问它们的方式:

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

我还尝试对 NSDictionary 对象和键的操作使用 setTitleTextAttributes 但没有成功。有什么想法吗?

最佳答案

这已经过测试并且可以工作 - 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];

关于ios - UIAlertController 的 NSTextAlignmentLeft,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29666192/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com