Текст кнопки UIActionSheet не отображается должным образом в iOS 8

Я пытаюсь создать небольшой пользовательский интерфейс UIActionSheet. Я хочу отображать большой текст в кнопке UIActionSheet. Этот код отлично работает под iOS 8, но в 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;
        }

    }
}

}


person Saggy    schedule 09.10.2014    source источник


Ответы (1)


UIActionSheet устарел в iOS 8, поэтому используйте UIAlertController

проверьте эту ссылку 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

person Waseem Shah    schedule 09.10.2014
comment
спасибо .. ты экономишь мое время - person Saggy; 09.10.2014
comment
Я также хочу настроить шрифт текста в UIAlertController. Есть ли какой-либо метод делегата для UIAlertController? - person Saggy; 10.10.2014