9
This commit is contained in:
@@ -21,6 +21,8 @@
|
|||||||
0477BE042EBC83130055D639 /* HomeMainVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BE032EBC83130055D639 /* HomeMainVC.m */; };
|
0477BE042EBC83130055D639 /* HomeMainVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BE032EBC83130055D639 /* HomeMainVC.m */; };
|
||||||
047C650D2EBC8A840035E841 /* KBPanModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650C2EBC8A840035E841 /* KBPanModalView.m */; };
|
047C650D2EBC8A840035E841 /* KBPanModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650C2EBC8A840035E841 /* KBPanModalView.m */; };
|
||||||
047C65102EBCA8DD0035E841 /* HomeRankContentVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650F2EBCA8DD0035E841 /* HomeRankContentVC.m */; };
|
047C65102EBCA8DD0035E841 /* HomeRankContentVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650F2EBCA8DD0035E841 /* HomeRankContentVC.m */; };
|
||||||
|
047C655C2EBCD0F80035E841 /* UIView+KBShadow.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C655B2EBCD08E0035E841 /* UIView+KBShadow.m */; };
|
||||||
|
047C655E2EBCD5B20035E841 /* UIImage+KBColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C655D2EBCD5B20035E841 /* UIImage+KBColor.m */; };
|
||||||
047C652D2EBCAAAC0035E841 /* crab_selected.png in Resources */ = {isa = PBXBuildFile; fileRef = 047C651F2EBCAAAC0035E841 /* crab_selected.png */; };
|
047C652D2EBCAAAC0035E841 /* crab_selected.png in Resources */ = {isa = PBXBuildFile; fileRef = 047C651F2EBCAAAC0035E841 /* crab_selected.png */; };
|
||||||
047C652E2EBCAAAC0035E841 /* crab.png in Resources */ = {isa = PBXBuildFile; fileRef = 047C651E2EBCAAAC0035E841 /* crab.png */; };
|
047C652E2EBCAAAC0035E841 /* crab.png in Resources */ = {isa = PBXBuildFile; fileRef = 047C651E2EBCAAAC0035E841 /* crab.png */; };
|
||||||
047C652F2EBCAAAC0035E841 /* arrow_down.png in Resources */ = {isa = PBXBuildFile; fileRef = 047C651A2EBCAAAC0035E841 /* arrow_down.png */; };
|
047C652F2EBCAAAC0035E841 /* arrow_down.png in Resources */ = {isa = PBXBuildFile; fileRef = 047C651A2EBCAAAC0035E841 /* arrow_down.png */; };
|
||||||
@@ -185,6 +187,10 @@
|
|||||||
047C65522EBCBAC60035E841 /* KBCommunityVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBCommunityVC.m; sourceTree = "<group>"; };
|
047C65522EBCBAC60035E841 /* KBCommunityVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBCommunityVC.m; sourceTree = "<group>"; };
|
||||||
047C65562EBCC06D0035E841 /* HomeRankCardCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRankCardCell.h; sourceTree = "<group>"; };
|
047C65562EBCC06D0035E841 /* HomeRankCardCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRankCardCell.h; sourceTree = "<group>"; };
|
||||||
047C65572EBCC06D0035E841 /* HomeRankCardCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeRankCardCell.m; sourceTree = "<group>"; };
|
047C65572EBCC06D0035E841 /* HomeRankCardCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeRankCardCell.m; sourceTree = "<group>"; };
|
||||||
|
047C655A2EBCD08E0035E841 /* UIView+KBShadow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIView+KBShadow.h"; sourceTree = "<group>"; };
|
||||||
|
047C655B2EBCD08E0035E841 /* UIView+KBShadow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIView+KBShadow.m"; sourceTree = "<group>"; };
|
||||||
|
047C655C2EBCD5B20035E841 /* UIImage+KBColor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImage+KBColor.h"; sourceTree = "<group>"; };
|
||||||
|
047C655D2EBCD5B20035E841 /* UIImage+KBColor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImage+KBColor.m"; sourceTree = "<group>"; };
|
||||||
04A9A67D2EB9E1690023B8F4 /* KBResponderUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBResponderUtils.h; sourceTree = "<group>"; };
|
04A9A67D2EB9E1690023B8F4 /* KBResponderUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBResponderUtils.h; sourceTree = "<group>"; };
|
||||||
04A9FE102EB4D0D20020DB6D /* KBFullAccessManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBFullAccessManager.h; sourceTree = "<group>"; };
|
04A9FE102EB4D0D20020DB6D /* KBFullAccessManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBFullAccessManager.h; sourceTree = "<group>"; };
|
||||||
04A9FE112EB4D0D20020DB6D /* KBFullAccessManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBFullAccessManager.m; sourceTree = "<group>"; };
|
04A9FE112EB4D0D20020DB6D /* KBFullAccessManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBFullAccessManager.m; sourceTree = "<group>"; };
|
||||||
@@ -777,6 +783,10 @@
|
|||||||
04FC97082EB31B14007BD342 /* KBHUD.m */,
|
04FC97082EB31B14007BD342 /* KBHUD.m */,
|
||||||
04A9FE142EB873C80020DB6D /* UIViewController+Extension.h */,
|
04A9FE142EB873C80020DB6D /* UIViewController+Extension.h */,
|
||||||
04A9FE152EB873C80020DB6D /* UIViewController+Extension.m */,
|
04A9FE152EB873C80020DB6D /* UIViewController+Extension.m */,
|
||||||
|
047C655A2EBCD08E0035E841 /* UIView+KBShadow.h */,
|
||||||
|
047C655B2EBCD08E0035E841 /* UIView+KBShadow.m */,
|
||||||
|
047C655C2EBCD5B20035E841 /* UIImage+KBColor.h */,
|
||||||
|
047C655D2EBCD5B20035E841 /* UIImage+KBColor.m */,
|
||||||
);
|
);
|
||||||
path = Categories;
|
path = Categories;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -1146,6 +1156,8 @@
|
|||||||
0477BDF72EBC63A80055D639 /* KBTestVC.m in Sources */,
|
0477BDF72EBC63A80055D639 /* KBTestVC.m in Sources */,
|
||||||
04FC95C92EB1E4C9007BD342 /* BaseNavigationController.m in Sources */,
|
04FC95C92EB1E4C9007BD342 /* BaseNavigationController.m in Sources */,
|
||||||
047C65102EBCA8DD0035E841 /* HomeRankContentVC.m in Sources */,
|
047C65102EBCA8DD0035E841 /* HomeRankContentVC.m in Sources */,
|
||||||
|
047C655C2EBCD0F80035E841 /* UIView+KBShadow.m in Sources */,
|
||||||
|
047C655E2EBCD5B20035E841 /* UIImage+KBColor.m in Sources */,
|
||||||
04FC95DD2EB202A3007BD342 /* KBGuideVC.m in Sources */,
|
04FC95DD2EB202A3007BD342 /* KBGuideVC.m in Sources */,
|
||||||
04FC95E52EB220B5007BD342 /* UIColor+Extension.m in Sources */,
|
04FC95E52EB220B5007BD342 /* UIColor+Extension.m in Sources */,
|
||||||
0477BDF02EBB76E30055D639 /* HomeSheetVC.m in Sources */,
|
0477BDF02EBB76E30055D639 /* HomeSheetVC.m in Sources */,
|
||||||
|
|||||||
6
keyBoard/Assets.xcassets/Home/Contents.json
Normal file
6
keyBoard/Assets.xcassets/Home/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
22
keyBoard/Assets.xcassets/Home/home_bg_image.imageset/Contents.json
vendored
Normal file
22
keyBoard/Assets.xcassets/Home/home_bg_image.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "home_bg_image 1.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "home_bg_image 2.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
keyBoard/Assets.xcassets/Home/home_bg_image.imageset/home_bg_image 1.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/Home/home_bg_image.imageset/home_bg_image 1.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 397 KiB |
BIN
keyBoard/Assets.xcassets/Home/home_bg_image.imageset/home_bg_image 2.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/Home/home_bg_image.imageset/home_bg_image 2.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 397 KiB |
42
keyBoard/Class/Categories/UIImage+KBColor.h
Normal file
42
keyBoard/Class/Categories/UIImage+KBColor.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// UIImage+KBColor.h
|
||||||
|
// keyBoard
|
||||||
|
//
|
||||||
|
// 颜色/渐变 生成图片工具
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, KBGradientDirection) {
|
||||||
|
KBGradientDirectionLeftToRight = 0, // 左 → 右
|
||||||
|
KBGradientDirectionTopToBottom, // 上 → 下
|
||||||
|
KBGradientDirectionLeftTopToRightBottom,// 左上 → 右下
|
||||||
|
KBGradientDirectionLeftBottomToRightTop // 左下 → 右上
|
||||||
|
};
|
||||||
|
|
||||||
|
@interface UIImage (KBColor)
|
||||||
|
|
||||||
|
/// 用纯色生成图片
|
||||||
|
+ (UIImage *)kb_imageWithColor:(UIColor *)color size:(CGSize)size;
|
||||||
|
|
||||||
|
/// 用纯色生成圆角图片
|
||||||
|
+ (UIImage *)kb_imageWithColor:(UIColor *)color size:(CGSize)size cornerRadius:(CGFloat)cornerRadius;
|
||||||
|
|
||||||
|
/// 生成渐变图片(默认均匀分布)
|
||||||
|
+ (UIImage *)kb_gradientImageWithColors:(NSArray<UIColor *> *)colors
|
||||||
|
size:(CGSize)size
|
||||||
|
direction:(KBGradientDirection)direction;
|
||||||
|
|
||||||
|
/// 生成渐变图片(可指定 locations 与圆角)
|
||||||
|
+ (UIImage *)kb_gradientImageWithColors:(NSArray<UIColor *> *)colors
|
||||||
|
locations:(NSArray<NSNumber *> * _Nullable)locations
|
||||||
|
size:(CGSize)size
|
||||||
|
direction:(KBGradientDirection)direction
|
||||||
|
cornerRadius:(CGFloat)cornerRadius;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
86
keyBoard/Class/Categories/UIImage+KBColor.m
Normal file
86
keyBoard/Class/Categories/UIImage+KBColor.m
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
//
|
||||||
|
// UIImage+KBColor.m
|
||||||
|
// keyBoard
|
||||||
|
//
|
||||||
|
// 颜色/渐变 生成图片工具
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "UIImage+KBColor.h"
|
||||||
|
|
||||||
|
@implementation UIImage (KBColor)
|
||||||
|
|
||||||
|
+ (UIImage *)kb_imageWithColor:(UIColor *)color size:(CGSize)size {
|
||||||
|
return [self kb_imageWithColor:color size:size cornerRadius:0];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (UIImage *)kb_imageWithColor:(UIColor *)color size:(CGSize)size cornerRadius:(CGFloat)cornerRadius {
|
||||||
|
if (size.width <= 0 || size.height <= 0 || !color) { return nil; }
|
||||||
|
CGRect rect = (CGRect){CGPointZero, size};
|
||||||
|
UIGraphicsBeginImageContextWithOptions(size, NO, 0); // 0 => 使用设备 scale
|
||||||
|
CGContextRef ctx = UIGraphicsGetCurrentContext();
|
||||||
|
if (cornerRadius > 0) {
|
||||||
|
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:cornerRadius];
|
||||||
|
[path addClip];
|
||||||
|
}
|
||||||
|
CGContextSetFillColorWithColor(ctx, color.CGColor);
|
||||||
|
CGContextFillRect(ctx, rect);
|
||||||
|
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
|
||||||
|
UIGraphicsEndImageContext();
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (UIImage *)kb_gradientImageWithColors:(NSArray<UIColor *> *)colors
|
||||||
|
size:(CGSize)size
|
||||||
|
direction:(KBGradientDirection)direction {
|
||||||
|
return [self kb_gradientImageWithColors:colors locations:nil size:size direction:direction cornerRadius:0];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (UIImage *)kb_gradientImageWithColors:(NSArray<UIColor *> *)colors
|
||||||
|
locations:(NSArray<NSNumber *> * _Nullable)locations
|
||||||
|
size:(CGSize)size
|
||||||
|
direction:(KBGradientDirection)direction
|
||||||
|
cornerRadius:(CGFloat)cornerRadius {
|
||||||
|
if (colors.count == 0 || size.width <= 0 || size.height <= 0) { return nil; }
|
||||||
|
// 构造渐变层
|
||||||
|
CAGradientLayer *layer = [CAGradientLayer layer];
|
||||||
|
layer.frame = (CGRect){CGPointZero, size};
|
||||||
|
NSMutableArray *cgColors = [NSMutableArray arrayWithCapacity:colors.count];
|
||||||
|
for (UIColor *c in colors) { [cgColors addObject:(id)c.CGColor]; }
|
||||||
|
layer.colors = cgColors;
|
||||||
|
if (locations.count == colors.count) { layer.locations = locations; }
|
||||||
|
|
||||||
|
// 方向 -> 起止点
|
||||||
|
switch (direction) {
|
||||||
|
case KBGradientDirectionLeftToRight:
|
||||||
|
layer.startPoint = CGPointMake(0, 0.5);
|
||||||
|
layer.endPoint = CGPointMake(1, 0.5);
|
||||||
|
break;
|
||||||
|
case KBGradientDirectionTopToBottom:
|
||||||
|
layer.startPoint = CGPointMake(0.5, 0);
|
||||||
|
layer.endPoint = CGPointMake(0.5, 1);
|
||||||
|
break;
|
||||||
|
case KBGradientDirectionLeftTopToRightBottom:
|
||||||
|
layer.startPoint = CGPointMake(0, 0);
|
||||||
|
layer.endPoint = CGPointMake(1, 1);
|
||||||
|
break;
|
||||||
|
case KBGradientDirectionLeftBottomToRightTop:
|
||||||
|
layer.startPoint = CGPointMake(0, 1);
|
||||||
|
layer.endPoint = CGPointMake(1, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cornerRadius > 0) {
|
||||||
|
layer.cornerRadius = cornerRadius;
|
||||||
|
layer.masksToBounds = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
UIGraphicsBeginImageContextWithOptions(size, NO, 0);
|
||||||
|
CGContextRef ctx = UIGraphicsGetCurrentContext();
|
||||||
|
[layer renderInContext:ctx];
|
||||||
|
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
|
||||||
|
UIGraphicsEndImageContext();
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
34
keyBoard/Class/Categories/UIView+KBShadow.h
Normal file
34
keyBoard/Class/Categories/UIView+KBShadow.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// UIView+KBShadow.h
|
||||||
|
// keyBoard
|
||||||
|
//
|
||||||
|
// 基础阴影封装:一行设置卡片阴影,支持圆角与路径缓存
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface UIView (KBShadow)
|
||||||
|
|
||||||
|
/// 便捷方法:设置卡片阴影(常用黑色、透明度0.15、半径10、偏移(0,6))并记录圆角和内边距,用于后续更新路径
|
||||||
|
- (void)kb_setCardShadowWithCornerRadius:(CGFloat)cornerRadius insets:(UIEdgeInsets)insets;
|
||||||
|
|
||||||
|
/// 自定义阴影参数;同时记录 cornerRadius 与 insets,供 `kb_updateShadowPath` 使用
|
||||||
|
- (void)kb_setShadowWithColor:(UIColor *)color
|
||||||
|
opacity:(float)opacity
|
||||||
|
radius:(CGFloat)radius
|
||||||
|
offset:(CGSize)offset
|
||||||
|
cornerRadius:(CGFloat)cornerRadius
|
||||||
|
insets:(UIEdgeInsets)insets;
|
||||||
|
|
||||||
|
/// 在 `layoutSubviews` 等尺寸变化后调用,按记录的 cornerRadius 与 insets 更新 shadowPath
|
||||||
|
- (void)kb_updateShadowPath;
|
||||||
|
|
||||||
|
/// 移除阴影(清理 shadowPath)
|
||||||
|
- (void)kb_removeShadow;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
65
keyBoard/Class/Categories/UIView+KBShadow.m
Normal file
65
keyBoard/Class/Categories/UIView+KBShadow.m
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
//
|
||||||
|
// UIView+KBShadow.m
|
||||||
|
// keyBoard
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "UIView+KBShadow.h"
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
|
static const void *kKBShadowInsetsKey = &kKBShadowInsetsKey;
|
||||||
|
static const void *kKBShadowCornerRadiusKey = &kKBShadowCornerRadiusKey;
|
||||||
|
|
||||||
|
@implementation UIView (KBShadow)
|
||||||
|
|
||||||
|
- (void)kb_setCardShadowWithCornerRadius:(CGFloat)cornerRadius insets:(UIEdgeInsets)insets {
|
||||||
|
[self kb_setShadowWithColor:[UIColor blackColor]
|
||||||
|
opacity:0.15f
|
||||||
|
radius:10.0
|
||||||
|
offset:CGSizeMake(0, 6)
|
||||||
|
cornerRadius:cornerRadius
|
||||||
|
insets:insets];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)kb_setShadowWithColor:(UIColor *)color
|
||||||
|
opacity:(float)opacity
|
||||||
|
radius:(CGFloat)radius
|
||||||
|
offset:(CGSize)offset
|
||||||
|
cornerRadius:(CGFloat)cornerRadius
|
||||||
|
insets:(UIEdgeInsets)insets {
|
||||||
|
CALayer *layer = self.layer;
|
||||||
|
layer.masksToBounds = NO; // 需要让阴影显示在边界外
|
||||||
|
layer.shadowColor = color.CGColor;
|
||||||
|
layer.shadowOpacity = opacity;
|
||||||
|
layer.shadowRadius = radius;
|
||||||
|
layer.shadowOffset = offset;
|
||||||
|
|
||||||
|
// 记录参数,供尺寸变化后更新路径
|
||||||
|
objc_setAssociatedObject(self, kKBShadowInsetsKey, [NSValue valueWithUIEdgeInsets:insets], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
|
objc_setAssociatedObject(self, kKBShadowCornerRadiusKey, @(cornerRadius), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
|
|
||||||
|
// 初次也设置一次路径(避免首次 layout 之前看不到阴影)
|
||||||
|
[self kb_updateShadowPath];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)kb_updateShadowPath {
|
||||||
|
NSValue *insetsVal = objc_getAssociatedObject(self, kKBShadowInsetsKey);
|
||||||
|
NSNumber *cornerVal = objc_getAssociatedObject(self, kKBShadowCornerRadiusKey);
|
||||||
|
if (!insetsVal || !cornerVal) return;
|
||||||
|
UIEdgeInsets insets = [insetsVal UIEdgeInsetsValue];
|
||||||
|
CGFloat corner = (CGFloat)[cornerVal doubleValue];
|
||||||
|
CGRect rect = UIEdgeInsetsInsetRect(self.bounds, insets);
|
||||||
|
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:corner];
|
||||||
|
self.layer.shadowPath = path.CGPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)kb_removeShadow {
|
||||||
|
CALayer *layer = self.layer;
|
||||||
|
layer.shadowOpacity = 0;
|
||||||
|
layer.shadowPath = nil;
|
||||||
|
objc_setAssociatedObject(self, kKBShadowInsetsKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
|
objc_setAssociatedObject(self, kKBShadowCornerRadiusKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
- (instancetype)initWithFrame:(CGRect)frame{
|
- (instancetype)initWithFrame:(CGRect)frame{
|
||||||
if (self = [super initWithFrame:frame]) {
|
if (self = [super initWithFrame:frame]) {
|
||||||
self.backgroundColor = [UIColor blueColor];
|
self.backgroundColor = [UIColor clearColor];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
@import UIKit;
|
@import UIKit;
|
||||||
#import "HomeRankCardCell.h"
|
#import "HomeRankCardCell.h"
|
||||||
|
#import "UIView+KBShadow.h"
|
||||||
|
|
||||||
@interface HomeRankCardCell ()
|
@interface HomeRankCardCell ()
|
||||||
@property (nonatomic, strong) UIView *shadowView; // 阴影容器(不裁剪)
|
@property (nonatomic, strong) UIView *shadowView; // 阴影容器(不裁剪)
|
||||||
@@ -39,6 +40,9 @@
|
|||||||
[self.cardView addSubview:self.descLabel];
|
[self.cardView addSubview:self.descLabel];
|
||||||
[self.cardView addSubview:self.peopleLabel];
|
[self.cardView addSubview:self.peopleLabel];
|
||||||
[self.cardView addSubview:self.actionBtn];
|
[self.cardView addSubview:self.actionBtn];
|
||||||
|
|
||||||
|
// 统一阴影封装:在阴影容器上添加卡片阴影,阴影路径根据卡片左右 8pt 内边距进行收缩
|
||||||
|
[self.shadowView kb_setCardShadowWithCornerRadius:18.0 insets:UIEdgeInsetsMake(0, 8, 0, 8)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setupConstraints {
|
- (void)setupConstraints {
|
||||||
@@ -86,13 +90,8 @@
|
|||||||
|
|
||||||
- (void)layoutSubviews {
|
- (void)layoutSubviews {
|
||||||
[super layoutSubviews];
|
[super layoutSubviews];
|
||||||
// 添加柔和阴影
|
// 阴影路径需在尺寸确定后更新(封装方法会基于记录参数自动计算)
|
||||||
_shadowView.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.15].CGColor;
|
[self.shadowView kb_updateShadowPath];
|
||||||
_shadowView.layer.shadowOpacity = 1.0;
|
|
||||||
_shadowView.layer.shadowRadius = 10.0;
|
|
||||||
_shadowView.layer.shadowOffset = CGSizeMake(0, 6);
|
|
||||||
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:_cardView.bounds cornerRadius:18.0];
|
|
||||||
_shadowView.layer.shadowPath = path.CGPath;
|
|
||||||
|
|
||||||
_badgeCircle.layer.cornerRadius = 34;
|
_badgeCircle.layer.cornerRadius = 34;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,10 @@
|
|||||||
|
|
||||||
- (instancetype)initWithFrame:(CGRect)frame{
|
- (instancetype)initWithFrame:(CGRect)frame{
|
||||||
if (self = [super initWithFrame:frame]) {
|
if (self = [super initWithFrame:frame]) {
|
||||||
self.backgroundColor = [UIColor redColor];
|
// self.backgroundColor = [UIColor redColor];
|
||||||
HWBackgroundConfig *config = [HWBackgroundConfig configWithBehavior:HWBackgroundBehaviorDefault];
|
// HWBackgroundConfig *config = [HWBackgroundConfig configWithBehavior:HWBackgroundBehaviorDefault];
|
||||||
config = [HWBackgroundConfig configWithBehavior:HWBackgroundBehaviorDefault];
|
// config.backgroundAlpha = 0;
|
||||||
config.backgroundAlpha = 0.01;
|
// [self.hw_dimmedView reloadConfig:config];
|
||||||
[self.hw_dimmedView reloadConfig:config];
|
|
||||||
// 顶部按钮 + 容器
|
// 顶部按钮 + 容器
|
||||||
[self setupTopButtonsAndContainer];
|
[self setupTopButtonsAndContainer];
|
||||||
// 默认展示“热门”
|
// 默认展示“热门”
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
@interface HomeMainVC ()
|
@interface HomeMainVC ()
|
||||||
@property (nonatomic, strong) HomeHeadView *headView;
|
@property (nonatomic, strong) HomeHeadView *headView;
|
||||||
|
@property (nonatomic, strong) KBPanModalView *simplePanModalView;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -19,22 +20,32 @@
|
|||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
|
|
||||||
self.view.backgroundColor = [UIColor yellowColor];
|
// self.view.backgroundColor = [UIColor yellowColor];
|
||||||
|
UIImage *bgImage = [UIImage kb_gradientImageWithColors:@[[UIColor colorWithHex:0xE8FFF1], [UIColor colorWithHex:0xD4FDFF]] size:CGSizeMake(KB_SCREEN_WIDTH, KB_SCREEN_HEIGHT) direction:KBGradientDirectionTopToBottom];
|
||||||
|
UIImageView *bgImageView = [[UIImageView alloc] init];
|
||||||
|
bgImageView.image = bgImage;
|
||||||
|
[self.view addSubview:bgImageView];
|
||||||
|
[bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.edges.equalTo(self.view);
|
||||||
|
}];
|
||||||
CGFloat topV = (500);
|
CGFloat topV = (500);
|
||||||
|
|
||||||
// [self.view addSubview:self.headView];
|
// [self.view addSubview:self.headView];
|
||||||
// [self setupMas:topV];
|
// [self setupMas:topV];
|
||||||
// 创建sheetVC
|
// 创建sheetVC
|
||||||
KBPanModalView *simplePanModalView = [[KBPanModalView alloc] init];
|
self.simplePanModalView = [[KBPanModalView alloc] init];
|
||||||
// 使用宏,避免误写成函数指针判断导致恒为 true
|
// 使用宏,避免误写成函数指针判断导致恒为 true
|
||||||
if (KB_DEVICE_HAS_NOTCH) {
|
if (KB_DEVICE_HAS_NOTCH) {
|
||||||
simplePanModalView.minHeight = KB_SCREEN_HEIGHT - topV - 34;
|
self.simplePanModalView.minHeight = KB_SCREEN_HEIGHT - topV - 34;
|
||||||
}else{
|
}else{
|
||||||
simplePanModalView.minHeight = KB_SCREEN_HEIGHT - topV;
|
self.simplePanModalView.minHeight = KB_SCREEN_HEIGHT - topV;
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
simplePanModalView.topInset = 100;
|
self.simplePanModalView.topInset = 100;
|
||||||
[simplePanModalView presentInView:self.view];
|
[self.simplePanModalView presentInView:self.view];
|
||||||
|
HWBackgroundConfig *config = [HWBackgroundConfig configWithBehavior:HWBackgroundBehaviorDefault];
|
||||||
|
config.backgroundAlpha = 0;
|
||||||
|
[self.simplePanModalView.hw_dimmedView reloadConfig:config];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setupMas:(CGFloat)headViewTopV{
|
- (void)setupMas:(CGFloat)headViewTopV{
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
self.view.backgroundColor = [UIColor redColor];
|
self.view.backgroundColor = [UIColor redColor];
|
||||||
HWBackgroundConfig *config = [HWBackgroundConfig configWithBehavior:HWBackgroundBehaviorDefault];
|
HWBackgroundConfig *config = [HWBackgroundConfig configWithBehavior:HWBackgroundBehaviorDefault];
|
||||||
config = [HWBackgroundConfig configWithBehavior:HWBackgroundBehaviorDefault];
|
config = [HWBackgroundConfig configWithBehavior:HWBackgroundBehaviorDefault];
|
||||||
config.backgroundAlpha = 0.01;
|
config.backgroundAlpha = 0.001;
|
||||||
[self.hw_dimmedView reloadConfig:config];
|
[self.hw_dimmedView reloadConfig:config];
|
||||||
|
|
||||||
// 顶部按钮 + 容器
|
// 顶部按钮 + 容器
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
|
|
||||||
|
|
||||||
/// 项目
|
/// 项目
|
||||||
|
#import "UIView+KBShadow.h"
|
||||||
|
#import "UIImage+KBColor.h"
|
||||||
|
#import "UIColor+Extension.h"
|
||||||
|
|
||||||
#import "UIViewController+Extension.h"
|
#import "UIViewController+Extension.h"
|
||||||
#import "BaseNavigationController.h"
|
#import "BaseNavigationController.h"
|
||||||
#import "BaseTableView.h"
|
#import "BaseTableView.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user