将字体大小设置为UIActionSheet标题

问题描述 投票:1回答:2

我需要设置大小UIActionSheet标题“选择复制选项”

enter image description here

使用此代码:

  [[UIActionSheet alloc] initWithTitle:@"Select option to copy:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
                                     otherButtonTitles:@"copy all ",nil];
objective-c uiactionsheet
2个回答
3
投票

您可以利用运行时属性来设置字体。通过使用NSAttributedString你可以实现这一目标。

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
                                     otherButtonTitles:@"copy all ",nil];

//Creating Attributed String with System Font size of 30.0f
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"Select option to copy:" attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:30.0f]}];

//Accessing the Alert View Controller property from Action Sheet
UIAlertController *alertController = [actionSheet valueForKey:@"_alertController"];

//Setting Attributed Title property of Alert View Controller
[alertController setValue:attrString forKey:@"_attributedTitle"];

//Displaying the Action Sheet
[actionSheet showInView:self.view];

enter image description here


0
投票

您可以使用此委托更改qazxsw poi的标题字体

uiactionsheet
© www.soinside.com 2019 - 2024. All rights reserved.