Draw text and add to a UIImage iOS 5/6

前端 未结 3 827
遇见更好的自我
遇见更好的自我 2020-12-16 05:57

I have a textbox, where i want the written text to be added to a UIImage.

How can i draw NSString to a UIImage?

I´ve searched, and found lots of examples, bu

3条回答
  •  感动是毒
    2020-12-16 06:56

    UIImage is not a subview of UIView, so you cant add a subview to it. Also NSString is not a subview of UIView. If you want to show things on the screen, they should inherit from UIView.

    So try this:

    Create a UIImageView - set its image property to be your UIImage instance.

    Create a UILabel - set its text property to your NSString.

    Add the UILabel as a subview of your UIImageView.

    and finally add your UIImageView to your current view controllers view.

提交回复
热议问题