Pictures have a large cut of the image is also occupied the size of the IPA, sometimes transduction only need to local or a compressed picture of the abstract state
Directly on the code
CGFloat top =Ten;//Top Cover HeightCGFloat Bottom=Ten;//Bottom Cover HeightCGFloat Left=Ten;//Left cover widthCGFloat Right=Ten;//right End cover widthuiedgeinsets insets=Uiedgeinsetsmake (top, left, bottom, right);[OptionButton setbackgroundimage:[[uiimage imagenamed:@"Hf_segment_control_left_normal"] resizableimagewithcapinsets:insets] forstate:uicontrolstatenormal];
//uiimageresizingmodestretch: Stretch mode to fill a picture by stretching the rectangular area specified by the Uiedgeinsets
//uiimageresizingmodetile: Tile mode, fills the map by repeating the uiedgeinsets specified rectangular area
A picture of the web, with an elephant tells you the existence of four width parameters, stretching is the middle black common zone
My sister on the use of the result map
: Product Manager Design Good beauty I like this style.
That's what it's like to have a very harmonious feeling after stretching.
Error Demonstration:
This picture has always been the size and proportions of the original image, I was crazy for a while, questioned why do not stretch the original to let the image stretch to use [UIButton setbackgroundimage:] I use is setimage: Can not make a big mistake, Setbackgroudim Age is the background tile setimage is the display of the picture. That is , the picture will not enlarge with the button, the picture is always the original image size, and the picture is set with the SetBackgroundImage method, and the picture will be enlarged as the button becomes larger.
Up posture haha setimage: Just the left is the picture to the right is Button.title
For example: Good beauty
IOS UIImage Stretching issues (for UIButton, etc. where local stretching is required)