Saggy
Saggy

Reputation: 465

UIActionSheet button text not displaying properly in ios 8

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

    }
}

}

Upvotes: 0

Views: 875

Answers (1)

Related Questions