美文网首页
ActionSheet标题定制

ActionSheet标题定制

作者: Fisher123 | 来源:发表于2017-12-29 22:37 被阅读81次
- (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标题效果如下图:

相关文章

网友评论

      本文标题:ActionSheet标题定制

      本文链接:https://www.haomeiwen.com/subject/rzwwgxtx.html