Reputation: 1780
I need to set size UIActionSheet title "Select option to Copy"
with this code :
[[UIActionSheet alloc] initWithTitle:@"Select option to copy:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
otherButtonTitles:@"copy all ",nil];
Upvotes: 1
Views: 4092
Reputation: 5343
You could take advantage of Runtime Properties to set the font. By using NSAttributedString
you can achieve this.
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];
Upvotes: 3
Reputation: 2566
You can change the title font of uiactionsheet
by using this delgate
-(void)willPresentActionSheet:(UIActionSheet *)actionSheet {
for (UIView *_currentView in actionSheet.subviews) {
if ([_currentView isKindOfClass:[UILabel class]]) {
UILabel *l = [[UILabel alloc] initWithFrame:_currentView.frame];
l.text = [(UILabel *)_currentView text];
[l setFont:[UIFont fontWithName:@"Arial-BoldMT" size:20]];
l.textColor = [UIColor darkGrayColor];
l.backgroundColor = [UIColor clearColor];
[l sizeToFit];
[l setCenter:CGPointMake(actionSheet.center.x, 25)];
[l setFrame:CGRectIntegral(l.frame)];
[actionSheet addSubview:l];
_currentView.hidden = YES;
break;
}
}
}
Upvotes: 0