Dav*_*dNg 18 sdk objective-c uialertview ios
我有兴趣制作一个左对齐的UIAlertView,其中有几行像公告列表一样,如下所示:
这是我到目前为止所拥有的:
alert = [[UIAlertView alloc] initWithTitle: @"How to use buttons"
message: @"line 1. line 2, line 3 "
delegate: nil
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
Run Code Online (Sandbox Code Playgroud)
我还想将警报视图的颜色更改为红色.
pas*_*aya 31
项目符号由unicode代码0x2022表示.我使用"\n"为新行开始这样工作:
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"How to use buttons"
message: [NSString stringWithFormat: @"%C line 1.\n %C line 2,\n %C line 3", (unichar) 0x2022, (unichar) 0x2022, (unichar) 0x2022];
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
Run Code Online (Sandbox Code Playgroud)
这应该适用于子弹.
对于左对齐,请执行以下操作:
NSArray *subViewArray = alertView.subviews;
for(int x = 0; x < [subViewArray count]; x++){
//If the current subview is a UILabel...
if([[[subViewArray objectAtIndex:x] class] isSubclassOfClass:[UILabel class]]) {
UILabel *label = [subViewArray objectAtIndex:x];
label.textAlignment = NSTextAlignmentLeft;
}
}
Run Code Online (Sandbox Code Playgroud)
总结如下:
[NSString stringWithFormat:@"%C Line n", (unichar) 0x2022];
对于子弹.UILabel
.然后使用标签将标签的文本对齐方式更改为左对齐label.textAlignment = NSTextAlignmentLeft
.[alert show];
. 归档时间: |
|
查看次数: |
20910 次 |
最近记录: |