UIActionSheet button text not displaying properly in ios 8
Asked Answered
T

1

0

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

    }
}

}

Towner answered 9/10, 2014 at 11:45 Comment(0)
F
1

UIActionSheet is deprecated in iOS 8 so please use UIAlertController

check this link https://developer.apple.com/library/ios/documentation/Uikit/reference/UIActionSheet_Class/index.html

https://developer.apple.com/library/ios/documentation/Uikit/reference/UIAlertController_class/index.html#//apple_ref/c/econst/UIAlertControllerStyleActionSheet

Freytag answered 9/10, 2014 at 11:50 Comment(2)
thnx.. u save my timeTowner
I also want to customize the the text font in UIAlertController. Is there any delegate method for UIAlertController?Towner

© 2022 - 2024 — McMap. All rights reserved.