将字体大小设置为UIActionSheet标题

时间:2015-11-23 08:11:04

标签: objective-c uiactionsheet

我需要设置尺寸UIActionSheet标题“选择要复制的选项”

enter image description here

使用此代码:

  [[UIActionSheet alloc] initWithTitle:@"Select option to copy:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
                                     otherButtonTitles:@"copy all ",nil];

1 个答案:

答案 0 :(得分:0)

您可以使用此delgate

更改uiactionsheet的标题字体
  -(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;
            }
        }
    }