ios - Xcode image slicing - stretch the outsides of the image but preserve an area in the centre -
i want use image slicing in xcode produce resizable image central area held static. seems impossible in xcode allows 1 stretched area , 1 shrunk area in each direction. correct?
does know of nice workaround this? need use image button can't arrangement of uiimageviews on top of each other unless pass touches through , gets bit messy.
many thanks.
as stretchableimagewithleftcapwidth
deprecated ios 5.0, can use resizableimagewithcapinsets
. check apple documentation, states,
you use method add cap insets image or change existing cap insets of image. in both cases, new image , original image remains untouched. example, can use method create background image button borders , corners: when button resized, corners of image remain unchanged, borders , center of image expand cover new size.
another method available, resizableimage(withcapinsets:resizingmode:)
if want set resizingmode
you can like,
uiimage *image = [uiimage imagenamed:@"yourimagename"]; uiimage *streachedimage = [image resizableimagewithcapinsets:uiedgeinsetsmake(5, 5, 5, 5)]; //edgeinsect want // or uiimage *streachedimage2 = [image resizableimagewithcapinsets:uiedgeinsetsmake(5, 5, 5, 5) resizingmode:uiimageresizingmodestretch]; // or uiimage *streachedimage3 = [image resizableimagewithcapinsets:uiedgeinsetsmake(5, 5, 5, 5) resizingmode:uiimageresizingmodetile];
check documentation more details.
update : (according comment)
you need set backgroundimage
, image
both button. can set image inset
manage image
's position.
Comments
Post a Comment