I'm trying to get some of the text in "message" for my UIAlertView to be bold. Like this:
UIAlertView message: Header some text, new header some more text
I've tried with basic html formatting (since "/n" works for new line), but that doesn't work for me. Is there an easy way to get some of the text bold?
Of course, if there isn't i can always write a customized implementation for an alertview, but if there's an easier way i would appriciate if someone could tell me :)
Here is the code you are looking for, without creating a custom alert
DOES NOT WORK ON iOS7
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"title" message:@"\n\n\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
UILabel *txtField = [[UILabel alloc] initWithFrame:CGRectMake(12.0, 25.0, 260.0, 95.0)];
[txtField setFont:[UIFont fontWithName:@"Helvetica-Bold" size:(18.0)]];
txtField.numberOfLines = 3;
txtField.textColor = [UIColor redColor];
txtField.text = @"Look at me, I am a Red and Bold Label.";
txtField.backgroundColor = [UIColor clearColor];
[alertView addSubview:txtField];
[alertView show];
It's all good if your app running under iOS 6 or lower, but unfortunately you can't add subviews to your alert view in iOS7. So if you need only to show message with bold font and you're not interested in creating custom views, you can simply add your text to title, when message leave empty.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Your message"
message:@""
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With