iphone - Stretching an UIImage while preserving the corners -
iphone - Stretching an UIImage while preserving the corners -
i'm trying stretch navigation arrow image while preserving edges middle stretches , ends fixed.
here image i'm trying stretch:
the next ios 5 code allows image when resized stretch center portions of image defined uiedgeinsets.
[[uiimage imagenamed:@"arrow.png"] resizableimagewithcapinsets:uiedgeinsetsmake(15, 7, 15, 15)];
this results in image looks (if image's frame set 70 pixels wide):
this want resizableimagewithcapinsets supported on ios 5 , later.
prior ios 5 similar method stretchableimagewithleftcapwidth:topcapheight can specify top , left insets means image has have equal shaped edges.
is there ios 4 way of resizing image same ios 5's resizableimagewithcapinsets
method, or way of doing this?
your assumption here wrong:
prior ios 5 similar method stretchableimagewithleftcapwidth:topcapheight can specify top , left insets which means image has have equal shaped edges.
the caps figured out follows - i'll step through left cap, same principle applies top cap.
say image 20px wide.
left cap width - part on left hand side of image cannot stretched. instretchableimage
method send value of 10 this. stretchable part - assumed 1 pixel in width, pixels in column "11", want of improve description this means there implied right cap of remaining 9px of image - not distorted. this taken documentation
leftcapwidth
end caps specify portion of image should not resized when image stretched. technique used implement buttons , other resizable image-based interface elements. when button end caps resized, resizing occurs in middle of button, in part between end caps. end caps maintain original size , appearance.
this property specifies size of left end cap. middle (stretchable) portion assumed 1 pixel wide. right end cap hence computed adding size of left end cap , middle portion , subtracting value width of image:
rightcapwidth = image.size.width - (image.leftcapwidth + 1);
iphone ios4 ios5 uiimage drawing
Comments
Post a Comment