Tuesday 8 April 2014

UIButton Or UILabel with underlined text. iOS 6 or iOS 7


//Button

NSMutableAttributedString *commentString = [[NSMutableAttributedString alloc] initWithString:@"ADD ANOTHER CONTACT"];

[commentString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [commentString length])];

// Or for adding Colored text use----------
    UIColor* textColor = [UIColor blueColor];


    [commentString setAttributes:@{NSForegroundColorAttributeName:textColor,NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle]} range:NSMakeRange(0,[commentString length])];


// Or for adding Colored text use----------


    [_addContactButton setAttributedTitle:commentString forState:UIControlStateNormal];




//Label

 NSMutableAttributedString *commentString = [[NSMutableAttributedString alloc] initWithString:@"ADD ANOTHER CONTACT"];
    
  UIColor* textColor = [UIColor blueColor];
    
[commentString setAttributes:@{NSForegroundColorAttributeName:textColor,NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle]} range:NSMakeRange(0,[commentString length])];
    
 [self.label setAttributedText:commentString];







5 comments:

  1. Whether you're implementing UIButton or UILabel with underlined text in iOS 6 or iOS 7, attention to detail matters. Just like precision in coding, prioritize your oral health. Explore Delhi Dentists for a seamless blend of technical finesse and a healthy smile. It's all about balance.

    ReplyDelete
  2. Enhance your gaming experience with our premier Rust game server. Secure, reliable, and customizable solutions tailored to your needs.

    ReplyDelete
  3. In iOS 6 or iOS 7, implementing underlined text in UIButton or UILabel adds versatility to user interfaces. Whether you're guiding users with buttons or displaying important information with labels, underlined text enhances readability and engagement. Just as a well-designed dinosaur statue captures attention, this subtle detail can elevate the overall aesthetic and functionality of your app.

    ReplyDelete