2014-10-09 65 views
0

我正在尝试创建UIActionSheet的少量客户UI。我想要在UIActionSheet的按钮中显示大文本。此代码是工作的罚款下面IOS 8,但在IOS 8 - (空)willPresentActionSheet:(UIActionSheet *)actionSheet {UIActionSheet按钮文本无法在ios 8中正确显示

for (UIView *subview in actionSheet.subviews) { 
    if ([subview isKindOfClass:[UIButton class]]) { 
     UIButton *button = (UIButton *)subview; 
     UIFont *textFont=[UIFont fontWithName:@"Palatino-Roman" size:12.0]; 
     button.titleLabel.font=textFont; 
     button.titleLabel.numberOfLines=4; 
     [button setContentHorizontalAlignment:UIControlContentVerticalAlignmentCenter]; 

     constrainedToSize:constraint1 lineBreakMode:NSLineBreakByWordWrapping]; 
     [button setFrame:CGRectMake(button.frame.origin.x+4,button.frame.origin.y+2,button.frame.size.width-4, button.frame.size.height)]; 

     if([[UIDevice currentDevice] systemVersion].floatValue<=5.0) 
     { 
      button.titleLabel.lineBreakMode = UILineBreakModeWordWrap; 
      button.titleLabel.textAlignment = UITextAlignmentCenter; 
     } 
     else 
     { 
      button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; 
      button.titleLabel.textAlignment = NSTextAlignmentCenter; 
     } 

    } 
} 

}

回答

1
+0

thnx .. u节省我的时间 – Saggy 2014-10-09 12:39:52

+0

我也想在UIAlertController中自定义文本字体。有没有UIAlertController的委托方法? – Saggy 2014-10-10 05:45:32

相关问题