Tef*_*ffi 9 objective-c uialertview uiactionsheet ios ios8
现在iOS8上的过时UIActionsheet和UIAlertview定制上iOS7工作不发生作用了.到目前为止,我所知道的唯一定制是色彩.我需要的是改变标题的字体大小和样式,我没有找到任何方式使用新的UIAlertAction.
已经提到了这个,但我仍然希望有一种方法可以至少改变标题大小和字体.
为您提供我的一些代码 UIAlertAction
UIAlertController * alertActionSheetController = [UIAlertController alertControllerWithTitle:@"Settings"
message:@""
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction * aboutTheAppAction = [UIAlertAction actionWithTitle:@"About the App"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action){
NSLog(@"About the app");
[self openAbout];
}];
[alertActionSheetController addAction:aboutTheAppAction];
[self presentViewController:alertActionSheetController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
Muh*_*saf 13
您可以更改UIAlertAction的字体和颜色.首先,您需要添加UILabel类别
@interface UILabel (FontAppearance)
@property (nonatomic, copy) UIFont * appearanceFont UI_APPEARANCE_SELECTOR;
@end
@implementation UILabel (FontAppearance)
-(void)setAppearanceFont:(UIFont *)font {
if (font)
[self setFont:font];
}
-(UIFont *)appearanceFont {
return self.font;
}
@end
Run Code Online (Sandbox Code Playgroud)
类别文件也在以下网址上传:https: //www.dropbox.com/s/em91fh00fv3ut4h/Archive.zip?dl = 0
导入该文件后您需要调用以下函数.
UILabel * appearanceLabel = [UILabel appearanceWhenContainedIn:UIAlertController.class, nil];
[appearanceLabel setAppearanceFont:yourDesireFont]];
Run Code Online (Sandbox Code Playgroud)
上面的代码是在颜色和字体上测试的.这只适用于iOS8或更高版本.
| 归档时间: |
|
| 查看次数: |
8808 次 |
| 最近记录: |