In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use Quartz2D, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Example 1: draw text
Create a string object and a dictionary to set the relevant properties for the string object, and use the string drawing method to draw it to a location or point.
The drawing of the rectangle will not be discussed here, but mainly about how to set the attribute dictionary of the text:
NSMutableDictionary * dict = [NSMutableDictionary new]
Dict [NSForegroundColorAttributeName] = [UIColor redColor]; / / text color
Dict [NSBackgroundColorAttributeName] = [UIColor greenColor]; / / text background color
Dict [NSFontAttributeName] = [UIFont systemFontOfSize:20]; / / text size
/ / you can start drawing.
NSString * str = @ "Test drawing text."
/ / start drawing at a certain coordinate, and the part beyond the screen will not wrap.
[str drawAtPoint:CGPoint (100100) withAttributes:dict]
/ / or draw to a certain range, if the width exceeds the width, the line will be wrapped automatically, and the part beyond the height will not be automatically adapted.
[str drawInRect:CGRectMake (100ppe 100pr 100pr 80) withAttributes:dict]
If you do not set the drawing attribute of the text, the parameter of the dictionary can be empty.
Example 2: draw a picture
/ / create an image object directly, and then use the corresponding draw method to draw it.
/ / Scheme 1: draw the picture to the specified range, the picture will not be compressed, it will be tiled to the specified range, and multiple pictures may be drawn according to the pixel ratio of the picture.
IUImage * p_w_picpath = [UIImage paired picpathNamedsaw @ ".png"]
[p_w_picpath drawAsPatternInRect:CGRectMake (100100320480)]
/ / option 2: draw the picture to the specified range, and the picture will be stretched to cover the specified area, and only one will be drawn.
[p_w_picpath drawInRect:CGRectMake (100100320480)]
/ / Plan 3: if you start drawing a picture from a certain point, it will automatically be drawn according to the scale of the picture, only once.
[p_w_picpath drawAtPoint:CGPoint (100100)]
Summary: because text and pictures are drawn without context rendering, you don't need to get context to operate at the beginning.
The above is all the contents of this article "how to use Quartz2D". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.