-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
[Tony]
committed
Jan 15, 2016
1 parent
55ca8d0
commit 27433fb
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// UIView+GTView.h | ||
// CAAnimationTest | ||
// | ||
// Created by Tony on 16/1/15. | ||
// Copyright © 2016年 JCH. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIView (GTView) | ||
|
||
/** | ||
* 为view(矩形)设置圆角 | ||
* | ||
* @param corners 指定哪个角设置为圆角(可以是一、二、三,四个角的话用下面的方法) | ||
* @param radii 圆角半径 | ||
*/ | ||
- (void)addCornerRadiusWithcorners:(UIRectCorner)corners AndRadii:(CGSize)radii; | ||
|
||
/** | ||
* 设置圆角矩形 | ||
* | ||
* @param cornerRadius 圆角半径 | ||
*/ | ||
- (void)addCornerRadiusWithRadius:(CGFloat)cornerRadius; | ||
|
||
@end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// UIView+GTView.m | ||
// CAAnimationTest | ||
// | ||
// Created by Tony on 16/1/15. | ||
// Copyright © 2016年 JCH. All rights reserved. | ||
// | ||
|
||
#import "UIView+GTView.h" | ||
|
||
@implementation UIView (GTView) | ||
|
||
- (void)addCornerRadiusWithcorners:(UIRectCorner)corners AndRadii:(CGSize)radii { | ||
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:radii]; | ||
CAShapeLayer *shapLayer = [[CAShapeLayer alloc]init]; | ||
shapLayer.path = bezierPath.CGPath; | ||
self.layer.mask = shapLayer; | ||
} | ||
|
||
- (void)addCornerRadiusWithRadius:(CGFloat)cornerRadius { | ||
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:cornerRadius]; | ||
CAShapeLayer *shapLayer = [[CAShapeLayer alloc]init]; | ||
shapLayer.path = bezierPath.CGPath; | ||
self.layer.mask = shapLayer; | ||
} | ||
|
||
@end |