You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/02/28 02:30:19 UTC
[39/50] incubator-weex git commit: * [ios] optimize calayer
* [ios] optimize calayer
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/530ae695
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/530ae695
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/530ae695
Branch: refs/heads/0.11-dev
Commit: 530ae69542e8cc5a7b81b6b39d9d69703bb108fb
Parents: 0057e0d
Author: \u9f50\u5c71 <su...@163.com>
Authored: Fri Feb 24 15:11:11 2017 +0800
Committer: \u9f50\u5c71 <su...@163.com>
Committed: Fri Feb 24 15:11:11 2017 +0800
----------------------------------------------------------------------
.../Sources/Display/WXComponent+BoxShadow.m | 31 +++++++++++---------
1 file changed, 17 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/530ae695/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.m
index 05e9e1c..feb456f 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.m
@@ -25,18 +25,20 @@
return boxShadow;
}
-- (void)resetViewLayer:(UIView *_Nullable)view lastBoxShadow:(WXBoxShadow *_Nullable)lastBoxShadow boxShadow:(WXBoxShadow *_Nullable)originalBoxShadow
+- (void)resetViewLayer
{
- UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:view.bounds];
- view.layer.masksToBounds = NO;
- view.layer.shadowColor = originalBoxShadow.shadowColor;
- view.layer.shadowOffset = originalBoxShadow.shadowOffset;
- view.layer.shadowRadius = originalBoxShadow.shadowRadius;
- view.layer.shadowOpacity = originalBoxShadow.shadowOpacity;
- view.layer.shadowPath = shadowPath.CGPath;
- if (lastBoxShadow.innerLayer) {
- if (lastBoxShadow.innerLayer) {
- [lastBoxShadow.innerLayer removeFromSuperlayer];
+ UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:self.view.bounds];
+ self.view.layer.masksToBounds = NO;
+ self.view.layer.shadowColor = _originalBoxShadow.shadowColor;
+ self.view.layer.shadowOffset = _originalBoxShadow.shadowOffset;
+ self.view.layer.shadowRadius = _originalBoxShadow.shadowRadius;
+ self.view.layer.shadowOpacity = _originalBoxShadow.shadowOpacity;
+ self.view.layer.shadowPath = shadowPath.CGPath;
+
+
+ if (_lastBoxShadow.isInset) {
+ if (_lastBoxShadow.innerLayer) {
+ [_lastBoxShadow.innerLayer removeFromSuperlayer];
}
}
}
@@ -64,15 +66,16 @@
if (!boxShadow && !_lastBoxShadow) {
return;
}
- [self resetViewLayer:view lastBoxShadow:_lastBoxShadow boxShadow:_originalBoxShadow];
+ [self resetViewLayer];
if (!boxShadow) {
return;
}
if (boxShadow.isInset) {
if (boxShadow.innerLayer) {
- [boxShadow.innerLayer removeFromSuperlayer];
boxShadow.innerLayer.frame = view.bounds;
- [view.layer addSublayer:boxShadow.innerLayer];
+ if (![boxShadow.innerLayer superlayer] ){
+ [view.layer addSublayer:boxShadow.innerLayer];
+ }
}
} else {
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:view.bounds];