本文介绍了UIActionSheet按钮文本在ios 8中无法正常显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建UIActionSheet的小客户UI。我想在UIActionSheet的按钮中显示大文本。此代码在ios 8下工作正常,但在ios 8
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{

I am trying to create little custome UI of UIActionSheet.I want to display the large text in button of UIActionSheet. This code is working fine below ios 8, But in ios 8 - (void)willPresentActionSheet:(UIActionSheet *)actionSheet{

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;
        }

    }
}

}

推荐答案

UIActionSheet在iOS 8中已弃用,因此请使用UIAlertController

UIActionSheet is deprecated in iOS 8 so please use UIAlertController

检查这个链接

这篇关于UIActionSheet按钮文本在ios 8中无法正常显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 22:50