Commit a91e72ed authored by 汪洋's avatar 汪洋

优化注释

parent 4d359407
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
// 注意只适用于UI规范中的导航范围:导航栏阴影,segment切换的阴影。
@interface UIView (NavigationShadow) @interface UIView (NavigationShadow)
/** /**
......
...@@ -17,43 +17,27 @@ ...@@ -17,43 +17,27 @@
@implementation UIView (NavigationShadow) @implementation UIView (NavigationShadow)
- (void)addNavigationShadow { - (void)addNavigationShadow {
self.layer.masksToBounds = NO; self.layer.masksToBounds = NO;
// self.layer.shadowOpacity = 1.0f;
// self.layer.shadowRadius = 2.0f;
// self.layer.shadowOffset = CGSizeMake(0.0, ONE_PIXEL);
// self.isShowShadow = YES;
// self.hideTopShadow = YES;
// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, self.bounds.size.height - 12, Constant.screenWidth, 12)];
// view.backgroundColor = [UIColor whiteColor];
// view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
// [self addSubview:view];
// [self sendSubviewToBack:view];
// view.layer.masksToBounds = NO;
// view.layer.shadowOpacity = 1.0f;
// view.layer.shadowRadius = 2.0f;
// view.layer.shadowOffset = CGSizeMake(0.0, ONE_PIXEL);
// //view.isShowShadow = YES;
// view.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.1].CGColor;
self.shadowLayer = [CALayer layer]; self.shadowLayer = [CALayer layer];
self.shadowLayer.bounds = CGRectMake(0, 0, Constant.screenWidth, 12); self.shadowLayer.bounds = CGRectMake(0, 0, Constant.screenWidth, 12);
self.shadowLayer.position = CGPointMake(self.bounds.size.width/2, self.bounds.size.height - 6); self.shadowLayer.position = CGPointMake(self.bounds.size.width/2, self.bounds.size.height - 6);
self.shadowLayer.backgroundColor = [UIColor whiteColor].CGColor; self.shadowLayer.backgroundColor = [UIColor whiteColor].CGColor;
[self.layer insertSublayer:self.shadowLayer atIndex:0];
self.shadowLayer.masksToBounds = NO; self.shadowLayer.masksToBounds = NO;
self.shadowLayer.shadowOpacity = 1.0f; self.shadowLayer.shadowOpacity = 1.0f;
self.shadowLayer.shadowRadius = 2.0f; self.shadowLayer.shadowRadius = 2.0f;
self.shadowLayer.shadowOffset = CGSizeMake(0.0, ONE_PIXEL); self.shadowLayer.shadowOffset = CGSizeMake(0.0, ONE_PIXEL);
self.isShowShadow = YES; self.isShowShadow = YES;
self.shadowLayer.shadowPath = CGPathCreateWithRect(CGRectMake(0, self.shadowLayer.bounds.size.height - 6, Constant.screenWidth, 6), nil); self.shadowLayer.shadowPath = CGPathCreateWithRect(CGRectMake(0, self.shadowLayer.bounds.size.height - 6, Constant.screenWidth, 6), nil);
self.shadowLayer.shadowColor = [UIColor colorWithWhite:0 alpha:0.1].CGColor;
} }
- (void)setIsShowShadow:(BOOL)isShowShadow { - (void)setIsShowShadow:(BOOL)isShowShadow {
objc_setAssociatedObject(self, @selector(isShowShadow), @(isShowShadow), OBJC_ASSOCIATION_RETAIN_NONATOMIC); objc_setAssociatedObject(self, @selector(isShowShadow), @(isShowShadow), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
if (isShowShadow) { if (isShowShadow && self.shadowLayer.superlayer == nil) {
self.shadowLayer.shadowColor = [UIColor colorWithWhite:0 alpha:0.1].CGColor; [self.layer insertSublayer:self.shadowLayer atIndex:0];
} else {
self.shadowLayer.shadowColor = [UIColor clearColor].CGColor; } else if (!isShowShadow && self.shadowLayer.superlayer != nil) {
[self.shadowLayer removeFromSuperlayer]; [self.shadowLayer removeFromSuperlayer];
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment