-
-
Save dsxsxsxs/544244d86984e3714d4834648776be7a 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 hidden or 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