---
title: "How to do formatting with UIActionSheet title string"  
description: "How to do formatting with UIActionSheet title string"  
author: "zack mathews"  
published: 2015-11-26  
updated: 2015-11-26  
canonical: https://www.mindstick.com/forum/33642/how-to-do-formatting-with-uiactionsheet-title-string  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# How to do formatting with UIActionSheet title string

Can we do formatting in the UIActionSheet [title](https://www.mindstick.com/articles/12860/how-to-get-financing-for-salvage-title-cars) [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp).

For example, if we have title string in two words like **'[Action](https://www.mindstick.com/forum/155752/what-is-action-result-with-its-types) Sheet'**,

now I want [word](https://www.mindstick.com/forum/305/read-word-file) **'Action'** should be [Bold](https://yourviews.mindstick.com/view/86882/adityanath-s-bold-assertion-krishna-asked-for-5-villages-we-want-3-centers) (with a particular [font size](https://www.mindstick.com/forum/158654/what-is-the-css-property-used-to-specify-the-font-size-of-an-element)) and the [second](https://answers.mindstick.com/qa/41761/how-did-the-second-industrial-revolution-influence-women-s-roles-in-society) string(**Sheet**) should be [Regular](https://www.mindstick.com/forum/220/problem-in-regular-expression-in-javascript) (no change).

\

Can we do like that?

[If yes](https://www.mindstick.com/forum/159589/can-we-crash-jvm-if-yes-then-how) then please tell me.!

## Replies

### Reply by Tarun Kumar

Yes, you can do formatting with the action sheet title,look my example I have created action sheet and give the title 'Action Sheet Demo'and use like my code, here is my code:

```
- (NSAttributedString *) actionSheetAttributedTitle;{    NSMutableAttributedString *attString1=[[NSMutableAttributedString alloc]                                          initWithString:@"Action "];    NSMutableAttributedString *attString2=[[NSMutableAttributedString alloc]                                          initWithString:@"Sheet "];    NSMutableAttributedString *attString3=[[NSMutableAttributedString alloc]                                          initWithString:@"Demo"];     UIFont *font1=[UIFont fontWithName:@"Helvetica-Bold" size:20.0f];    UIFont *font2=[UIFont fontWithName:@"Helvetica-Bold" size:20.0f];    UIFont *font3=[UIFont fontWithName:@"Helvetica-Bold" size:12.0f];     [attString1 addAttribute:NSFontAttributeName value:font1                                                 range:NSMakeRange(0,                                                 attString1.length)];    [attString1 addAttribute:NSForegroundColorAttributeName                                                 value:[UIColor redColor]                                                 range:NSMakeRange(0,                                                 attString1.length)];     [attString2 addAttribute:NSFontAttributeName value:font2                                                 range:NSMakeRange(0,                                                 attString2.length)];    [attString2 addAttribute:NSForegroundColorAttributeName                                                 value:[UIColor blueColor]                                                 range:NSMakeRange(0,                                                 attString2.length)];        [attString3 addAttribute:NSFontAttributeName value:font3                                                 range:NSMakeRange(0,                                                 attString3.length)];    [attString3 addAttribute:NSForegroundColorAttributeName                                                 value:[UIColor yellowColor]                                                 range:NSMakeRange(0,                                                 attString3.length)];        [attString1 appendAttributedString:attString2];    [attString1 appendAttributedString:attString3];     return [attString1 copy];}- (void)willPresentActionSheet:(UIActionSheet *)actionSheet;{        UILabel *sheetTitleLabel;        if([actionSheet respondsToSelector:@selector(_titleLabel)]) {        sheetTitleLabel = objc_msgSend(actionSheet, @selector(_titleLabel));        sheetTitleLabel.attributedText = [self actionSheetAttributedTitle];            }}
```


---

Original Source: https://www.mindstick.com/forum/33642/how-to-do-formatting-with-uiactionsheet-title-string

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
