This way, it can be saved and reapplied just like other layer properties.
This commit is contained in:
Justin Spahr-Summers 2012-11-25 23:17:06 -08:00
Родитель e0cbb42ea4
Коммит c48bb20e9d
2 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -22,6 +22,15 @@
// Defaults to NO. // Defaults to NO.
@property (nonatomic, assign) BOOL clipsToBounds; @property (nonatomic, assign) BOOL clipsToBounds;
// A radius used to draw rounded corners for the view's background. This property
// is not the same as CALayer.cornerRadius, but does manipulate it.
//
// Typically, you will want to enable clipsToBounds when setting this property
// to a non-zero value.
//
// Defaults to 0.
@property (nonatomic, assign) CGFloat cornerRadius;
// Whether the view's drawing completely fills its bounds with opaque content. // Whether the view's drawing completely fills its bounds with opaque content.
// //
// Defaults to NO. // Defaults to NO.

Просмотреть файл

@ -42,6 +42,11 @@ static IMP RBLViewDrawRectIMP;
[self applyLayerProperties]; [self applyLayerProperties];
} }
- (void)setCornerRadius:(CGFloat)radius {
_cornerRadius = radius;
[self applyLayerProperties];
}
- (BOOL)clipsToBounds { - (BOOL)clipsToBounds {
return _flags.clipsToBounds; return _flags.clipsToBounds;
} }
@ -170,6 +175,7 @@ static IMP RBLViewDrawRectIMP;
- (void)applyLayerProperties { - (void)applyLayerProperties {
self.layer.backgroundColor = self.backgroundColor.rbl_CGColor; self.layer.backgroundColor = self.backgroundColor.rbl_CGColor;
self.layer.cornerRadius = self.cornerRadius;
self.layer.masksToBounds = self.clipsToBounds; self.layer.masksToBounds = self.clipsToBounds;
self.layer.opaque = self.opaque; self.layer.opaque = self.opaque;
} }