I have a NSString object. I want to write it to existing UIImage object. UIImage object already has some image associate with it. I want to write string to same image. How do i achieve it?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
Here is my code. I have a 35x480 View and I draw text rotated by 90 degrees on it. I hope this helps. I draw the Image and then the text so it shows up. It looks like a window's window title.
I draw the image then the text on the drawRect.
An
NSString
cannot become aUIImage
. However, it sounds like all you want to do is plunk some text on top of an image, and that can be achieved easily.Create a
UILabel *label
. Set the text to your string withlabel.text = myString;
.Create a
UIImageView *imageView
. Set the image of the view to your image withimageView.image = myimage
.Add the
UILabel
as a subview of theUIImageView
(as a subclass ofUIView
, it takes subviews) with[imageView addSubview:label];
(or drop the label on the imageview if you're using the IB).Make sure to set the background of the label to
[UIColor clearColor]
or set thealpha = 0.0
so that it's transparent.EDIT: Following are basic step to achieve to edit an UIImage and write text on it.
It would be much easier to show text on and label and show that on image view. And answer for that are already there.
Then Update it to file or show it on the screen....
You would draw (composite) both the image and the string into a graphics context, and then grab the resulting UIImage.
To draw the image use
renderInContext
. To draw the text useCGContextShowTextAtPoint
. To get the resulting image