How to left-justify the title of UIActionSheet

2019-07-30 23:40发布

Is it possible to left-justify the title text of a UIActionSheet? Thanks!

4条回答
戒情不戒烟
2楼-- · 2019-07-30 23:54

You can simply use spaces after the name that you set for a button in UIActionsheet. For example if it is @"download" you can change to @"Download------------" which dashes here are spaces.

I hope it works.

查看更多
贪生不怕死
3楼-- · 2019-07-30 23:56

It is not possible to customize the title of an UIActionSheet. If you want something similar, you will have to design your own clone.

查看更多
\"骚年 ilove
4楼-- · 2019-07-30 23:58

yes, you can do it.

NSArray *subViewArray = yourActionSheet.subviews;
for(int x=0;x<[subViewArray count];x++){
    if([[[subViewArray objectAtIndex:x] class] isSubclassOfClass:[UILabel class]])
    {
        UILabel *label = [subViewArray objectAtIndex:x];
        label.textAlignment = NSTextAlignmentLeft;
    }

}
查看更多
时光不老,我们不散
5楼-- · 2019-07-31 00:00

Yes it is possible

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
    [actionSheet.subviews enumerateObjectsUsingBlock:^(id _currentView, NSUInteger idx, BOOL *stop) {
        if ([_currentView isKindOfClass:[UIButton class]]) {
            ((UIButton *)_currentView).contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
            ((UIButton *)_currentView).contentEdgeInsets = UIEdgeInsetsMake(0, 30, 0, 0);
        }
    }];
}
查看更多
登录 后发表回答