Created
July 29, 2017 07:15
-
-
Save brandhill/320b8a85b3eac607e3d8eda184427158 to your computer and use it in GitHub Desktop.
Equivalent Android 9-patch for iOS and Swift 3.0 (multiple stretchable areas)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// origin | |
UIImageView *unHandleImg = [[UIImageView alloc] initWithFrame:CGRectMake((SCREENWIDTH-200)/2, 100, 200, 30)]; | |
unHandleImg.image = [UIImage imageNamed:@"theImage"]; | |
[self.view addSubview:unHandleImg]; | |
// with stretchable | |
UIImageView *handleImg = [[UIImageView alloc] initWithFrame:CGRectMake((SCREENWIDTH-200)/2, 200, 200, 30)]; | |
UIImage *img = [UIImage imageNamed:@"theImage"]; | |
// stretchable areas | |
img = [img resizableImageWithCapInsets:UIEdgeInsetsMake(35, 35, 35, 35) resizingMode:UIImageResizingModeStretch]; | |
handleImg.image = img; | |
[self.view addSubview:handleImg]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment