Last active
December 16, 2016 05:16
-
-
Save iltercengiz/173060f878c0373d0b9a to your computer and use it in GitHub Desktop.
Masking views: http://www.objectivetidbits.com/2015/02/28/masking-views/
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
view.layer.cornerRadius = 8.0 |
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
imageView.layer.mask = starShape; |
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
CAShapeLayer *maskLayer = [CAShapeLayer new]; | |
maskLayer.frame = self.titleLabel.bounds; |
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
maskLayer.path = maskPath.CGPath; |
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
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.titleLabel.bounds | |
byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight | |
cornerRadii:CGSizeMake(8.0, 8.0)]; |
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
CAShapeLayer *starShape = [CAShapeLayer new]; | |
starShape.frame = imageView.bounds; | |
starShape.path = starPath.CGPath; |
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
UIBezierPath* starPath = UIBezierPath.bezierPath; | |
[starPath moveToPoint: CGPointMake(128, 0)]; | |
[starPath addLineToPoint: CGPointMake(156.58, 88.66)]; | |
[starPath addLineToPoint: CGPointMake(249.74, 88.45)]; | |
[starPath addLineToPoint: CGPointMake(174.24, 143.03)]; | |
[starPath addLineToPoint: CGPointMake(203.24, 231.55)]; | |
[starPath addLineToPoint: CGPointMake(128, 176.62)]; | |
[starPath addLineToPoint: CGPointMake(52.76, 231.55)]; | |
[starPath addLineToPoint: CGPointMake(81.76, 143.03)]; | |
[starPath addLineToPoint: CGPointMake(6.26, 88.45)]; | |
[starPath addLineToPoint: CGPointMake(99.42, 88.66)]; | |
[starPath closePath]; |
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
self.view.layer.mask = maskLayer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment