How to set NSString's background cornerRadius on iOS7

后端 未结 6 695
长情又很酷
长情又很酷 2020-12-01 02:12

I want to set NSString\'s background cornerRadius on iOS7. But,NSString don\'t have layer...

Please tell me, how to set NSString\'s background cornerRadius on iOS7?<

6条回答
  •  伪装坚强ぢ
    2020-12-01 03:06

    An NSString just defines a string of text. It doesn't define the properties of how it is rendered. For showing text on the screen, usually a UILabel or UITextView is used. However, for the selection behavior that you're showing in your example, you'll need to do that drawing yourself. Also it is changing the text color of the selected text, so you'll need to handle doing that yourself.

    If you created a custom UIView that allows you to draw the blue selection area, you could place that behind a UILabel, and you could use an NSAttributedString to set the text of the label where the "selected" text is white instead of black. That would probably be the simplest way to do this.

提交回复
热议问题