Is it possible to left-justify the title
text of a UIActionSheet
? Thanks!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
It is not possible to customize the title
of an UIActionSheet
. If you want something similar, you will have to design your own clone.
回答2:
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:
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;
}
}
回答4:
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);
}
}];
}