diff --git a/keyBoard.xcodeproj/project.pbxproj b/keyBoard.xcodeproj/project.pbxproj index 6b89a7e..775ebaf 100644 --- a/keyBoard.xcodeproj/project.pbxproj +++ b/keyBoard.xcodeproj/project.pbxproj @@ -72,6 +72,8 @@ 048908F52EC0496400FABA60 /* KBShopItemVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 048908F42EC0496400FABA60 /* KBShopItemVC.m */; }; 048909F62EC0AAAA00FABA60 /* KBCategoryTitleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 048909F12EC0AAAA00FABA60 /* KBCategoryTitleCell.m */; }; 048909F72EC0AAAA00FABA60 /* KBCategoryTitleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 048909F32EC0AAAA00FABA60 /* KBCategoryTitleView.m */; }; + 04890A042EC0BBBB00FABA60 /* KBCategoryTitleImageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 04890A012EC0BBBB00FABA60 /* KBCategoryTitleImageCell.m */; }; + 04890A052EC0BBBB00FABA60 /* KBCategoryTitleImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04890A032EC0BBBB00FABA60 /* KBCategoryTitleImageView.m */; }; 04A9FE0F2EB481100020DB6D /* KBHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC97082EB31B14007BD342 /* KBHUD.m */; }; 04A9FE132EB4D0D20020DB6D /* KBFullAccessManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A9FE112EB4D0D20020DB6D /* KBFullAccessManager.m */; }; 04A9FE162EB873C80020DB6D /* UIViewController+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A9FE152EB873C80020DB6D /* UIViewController+Extension.m */; }; @@ -254,6 +256,10 @@ 048909F12EC0AAAA00FABA60 /* KBCategoryTitleCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBCategoryTitleCell.m; sourceTree = ""; }; 048909F22EC0AAAA00FABA60 /* KBCategoryTitleView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBCategoryTitleView.h; sourceTree = ""; }; 048909F32EC0AAAA00FABA60 /* KBCategoryTitleView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBCategoryTitleView.m; sourceTree = ""; }; + 04890A002EC0BBBB00FABA60 /* KBCategoryTitleImageCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBCategoryTitleImageCell.h; sourceTree = ""; }; + 04890A012EC0BBBB00FABA60 /* KBCategoryTitleImageCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBCategoryTitleImageCell.m; sourceTree = ""; }; + 04890A022EC0BBBB00FABA60 /* KBCategoryTitleImageView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBCategoryTitleImageView.h; sourceTree = ""; }; + 04890A032EC0BBBB00FABA60 /* KBCategoryTitleImageView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBCategoryTitleImageView.m; sourceTree = ""; }; 04A9A67D2EB9E1690023B8F4 /* KBResponderUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBResponderUtils.h; sourceTree = ""; }; 04A9FE102EB4D0D20020DB6D /* KBFullAccessManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBFullAccessManager.h; sourceTree = ""; }; 04A9FE112EB4D0D20020DB6D /* KBFullAccessManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBFullAccessManager.m; sourceTree = ""; }; @@ -500,6 +506,10 @@ 048909F12EC0AAAA00FABA60 /* KBCategoryTitleCell.m */, 048909F22EC0AAAA00FABA60 /* KBCategoryTitleView.h */, 048909F32EC0AAAA00FABA60 /* KBCategoryTitleView.m */, + 04890A002EC0BBBB00FABA60 /* KBCategoryTitleImageCell.h */, + 04890A012EC0BBBB00FABA60 /* KBCategoryTitleImageCell.m */, + 04890A022EC0BBBB00FABA60 /* KBCategoryTitleImageView.h */, + 04890A032EC0BBBB00FABA60 /* KBCategoryTitleImageView.m */, ); path = V; sourceTree = ""; @@ -1306,6 +1316,8 @@ files = ( 048909F62EC0AAAA00FABA60 /* KBCategoryTitleCell.m in Sources */, 048909F72EC0AAAA00FABA60 /* KBCategoryTitleView.m in Sources */, + 04890A042EC0BBBB00FABA60 /* KBCategoryTitleImageCell.m in Sources */, + 04890A052EC0BBBB00FABA60 /* KBCategoryTitleImageView.m in Sources */, 04FC95E92EB23B67007BD342 /* KBNetworkManager.m in Sources */, 04FC95D22EB1E7AE007BD342 /* MyVC.m in Sources */, 047C65582EBCC06D0035E841 /* HomeRankCardCell.m in Sources */, diff --git a/keyBoard/Class/Home/VC/HomeRankVC.m b/keyBoard/Class/Home/VC/HomeRankVC.m index 8be82b6..19733bb 100644 --- a/keyBoard/Class/Home/VC/HomeRankVC.m +++ b/keyBoard/Class/Home/VC/HomeRankVC.m @@ -7,6 +7,7 @@ #import "HomeRankVC.h" #import "HomeRankContentVC.h" +#import "KBCategoryTitleImageView.h" @interface HomeRankVC () @property (nonatomic, strong) NSArray *titles; @@ -114,9 +115,10 @@ // 分页菜单视图 - (JXCategoryTitleImageView *)myCategoryView { if (!_myCategoryView) { - _myCategoryView = [[JXCategoryTitleImageView alloc] init]; + // Use our subclass so cells get a 4pt rounded background locally + _myCategoryView = (JXCategoryTitleImageView *)[[KBCategoryTitleImageView alloc] init]; _myCategoryView.delegate = self; - + // !!!: 将列表容器视图关联到 categoryView _myCategoryView.listContainer = self.listContainerView; } diff --git a/keyBoard/Class/Shop/V/KBCategoryTitleImageCell.h b/keyBoard/Class/Shop/V/KBCategoryTitleImageCell.h new file mode 100644 index 0000000..6e48cc7 --- /dev/null +++ b/keyBoard/Class/Shop/V/KBCategoryTitleImageCell.h @@ -0,0 +1,14 @@ +// +// KBCategoryTitleImageCell.h +// keyBoard +// +// A JXCategoryTitleImageCell subclass that rounds the cell's contentView +// without changing the third-party JXCategoryView source code. +// + +#import + +@interface KBCategoryTitleImageCell : JXCategoryTitleImageCell + +@end + diff --git a/keyBoard/Class/Shop/V/KBCategoryTitleImageCell.m b/keyBoard/Class/Shop/V/KBCategoryTitleImageCell.m new file mode 100644 index 0000000..a604c1d --- /dev/null +++ b/keyBoard/Class/Shop/V/KBCategoryTitleImageCell.m @@ -0,0 +1,28 @@ +// +// KBCategoryTitleImageCell.m +// keyBoard +// +// Sets `contentView.layer.cornerRadius = 4` for title+image cells, so the +// background color that JXCategoryView applies is shown as a rounded rect. +// + +#import "KBCategoryTitleImageCell.h" + +@implementation KBCategoryTitleImageCell + +- (void)initializeViews { + [super initializeViews]; + // Round the cell background once; keep clipping within the rounded rect. + self.contentView.layer.cornerRadius = 4.0; + self.contentView.layer.masksToBounds = YES; +} + +// Defensive: if layout changes reset layer (some frameworks tweak layers in layout) +- (void)layoutSubviews { + [super layoutSubviews]; + self.contentView.layer.cornerRadius = 4.0; + self.contentView.layer.masksToBounds = YES; +} + +@end + diff --git a/keyBoard/Class/Shop/V/KBCategoryTitleImageView.h b/keyBoard/Class/Shop/V/KBCategoryTitleImageView.h new file mode 100644 index 0000000..13e783c --- /dev/null +++ b/keyBoard/Class/Shop/V/KBCategoryTitleImageView.h @@ -0,0 +1,14 @@ +// +// KBCategoryTitleImageView.h +// keyBoard +// +// Registers KBCategoryTitleImageCell so we can round cells locally +// without touching the JXCategoryView pod. +// + +#import + +@interface KBCategoryTitleImageView : JXCategoryTitleImageView + +@end + diff --git a/keyBoard/Class/Shop/V/KBCategoryTitleImageView.m b/keyBoard/Class/Shop/V/KBCategoryTitleImageView.m new file mode 100644 index 0000000..720a977 --- /dev/null +++ b/keyBoard/Class/Shop/V/KBCategoryTitleImageView.m @@ -0,0 +1,18 @@ +// +// KBCategoryTitleImageView.m +// keyBoard +// +// Use our rounded KBCategoryTitleImageCell for this view instance. +// + +#import "KBCategoryTitleImageView.h" +#import "KBCategoryTitleImageCell.h" + +@implementation KBCategoryTitleImageView + +- (Class)preferredCellClass { + return [KBCategoryTitleImageCell class]; +} + +@end +