Bas*_*era 2 iphone xcode objective-c toast uialertview
我正在尝试在用户登录时提供 Toast 消息,并且用户将能够看到一条 Toast 消息,上面写着“新数据可用”和下方的按钮,上面写着“下载和取消”。但是当下载来时,它的字体以粗体出现。请让我知道怎么做默认情况下,我使这个看起来正常
代码如下:
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:msg message:@""delegate:self cancelButtonTitle:@"Download" otherButtonTitles: @"Ignore",nil];
Run Code Online (Sandbox Code Playgroud)
我需要下载应该在吐司消息中以普通字体出现。
我有一个简单的代码来提供 Toast。
- (void) ShowAlert:(NSString *)Message {
UIAlertController * alert=[UIAlertController alertControllerWithTitle:nil
message:@""
preferredStyle:UIAlertControllerStyleAlert];
UIView *firstSubview = alert.view.subviews.firstObject;
UIView *alertContentView = firstSubview.subviews.firstObject;
for (UIView *subSubView in alertContentView.subviews) {
subSubView.backgroundColor = [UIColor colorWithRed:141/255.0f green:0/255.0f blue:254/255.0f alpha:1.0f];
}
NSMutableAttributedString *AS = [[NSMutableAttributedString alloc] initWithString:Message];
[AS addAttribute: NSForegroundColorAttributeName value: [UIColor whiteColor] range: NSMakeRange(0,AS.length)];
[alert setValue:AS forKey:@"attributedTitle"];
[self presentViewController:alert animated:YES completion:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[alert dismissViewControllerAnimated:YES completion:^{
}];
});
}
Run Code Online (Sandbox Code Playgroud)
用
[self ShowAlert:@"Please Enter Your Good Name."];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6155 次 |
| 最近记录: |