- (void)setActionSheet {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:@"title" preferredStyle:UIAlertControllerStyleActionSheet];
NSMutableAttributedString *messageAttribute = [[NSMutableAttributedString alloc]initWithString:@"设置封面"];
[messageAttribute addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRGB:0x878787] range:NSMakeRange(0, title.length)];
[messageAttribute addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, title.length)];
[alertController setValue:messageAttribute forKey:@"attributedMessage"];
UIAlertAction *cameraAction = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self selectImageFromCamera];
}];
UIAlertAction *photoAction = [UIAlertAction actionWithTitle:@"从手机相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self selectImageFromPhotos];
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[alertController addAction:cameraAction];
[alertController addAction:photoAction];
[alertController addAction:cancelAction];
[self.NavigationController presentViewController:alertController animated:YES completion:nil];
}
ActionSheet标题效果如下图:
![](https://img.haomeiwen.com/i2822511/11bdd52dd56c16ae..jpg)
网友评论