2
This commit is contained in:
@@ -136,8 +136,8 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
|||||||
// 2 列
|
// 2 列
|
||||||
CGFloat spacing = 12.0;
|
CGFloat spacing = 12.0;
|
||||||
CGFloat itemW = floor((contentW - spacing) / 2.0);
|
CGFloat itemW = floor((contentW - spacing) / 2.0);
|
||||||
CGFloat itemH = itemW * 0.75 + 56; // 参考 KBSkinCardCell 内部布局
|
// CGFloat itemH = itemW * 0.75 + 56;
|
||||||
return CGSizeMake(itemW, itemH);
|
return CGSizeMake(itemW, KBFit(197));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CGSizeZero;
|
return CGSizeZero;
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/// 输入框
|
/// 输入框
|
||||||
@property (nonatomic, strong, readonly) UITextField *textField;
|
@property (nonatomic, strong, readonly) UITextField *textField;
|
||||||
|
|
||||||
|
/// 背景视图圆角(默认 20),外部可自定义。
|
||||||
|
@property (nonatomic, assign) CGFloat bgCornerRadius;
|
||||||
|
|
||||||
/// 点击键盘 return 或右侧按钮时回调
|
/// 点击键盘 return 或右侧按钮时回调
|
||||||
@property (nonatomic, copy) void(^onSearch)(NSString *keyword);
|
@property (nonatomic, copy) void(^onSearch)(NSString *keyword);
|
||||||
|
|
||||||
@@ -28,4 +31,3 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,8 @@
|
|||||||
_bgView = [[UIView alloc] init];
|
_bgView = [[UIView alloc] init];
|
||||||
// 淡灰色背景 + 圆角
|
// 淡灰色背景 + 圆角
|
||||||
_bgView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.0];
|
_bgView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.0];
|
||||||
_bgView.layer.cornerRadius = 20;
|
CGFloat radius = self.bgCornerRadius > 0 ? self.bgCornerRadius : 20.0;
|
||||||
|
_bgView.layer.cornerRadius = radius;
|
||||||
_bgView.layer.masksToBounds = YES;
|
_bgView.layer.masksToBounds = YES;
|
||||||
}
|
}
|
||||||
return _bgView;
|
return _bgView;
|
||||||
@@ -122,4 +123,12 @@
|
|||||||
self.textField.placeholder = placeholder;
|
self.textField.placeholder = placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setBgCornerRadius:(CGFloat)bgCornerRadius {
|
||||||
|
_bgCornerRadius = bgCornerRadius;
|
||||||
|
// 如果 bgView 已创建,立即更新圆角
|
||||||
|
if (_bgView) {
|
||||||
|
_bgView.layer.cornerRadius = bgCornerRadius;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -52,9 +52,10 @@ static NSString * const kResultCellId = @"KBSkinCardCell";
|
|||||||
[self.searchBarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.searchBarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.centerY.equalTo(self.backButton);
|
make.centerY.equalTo(self.backButton);
|
||||||
make.left.equalTo(self.backButton.mas_right).offset(12);
|
make.left.equalTo(self.backButton.mas_right).offset(12);
|
||||||
make.width.mas_equalTo(315);
|
// make.width.mas_equalTo(315);
|
||||||
make.height.mas_equalTo(36);
|
make.height.mas_equalTo(36);
|
||||||
make.right.lessThanOrEqualTo(self.topBar).offset(-16);
|
// make.right.lessThanOrEqualTo(self.topBar).offset(-16);
|
||||||
|
make.right.equalTo(self.view).offset(-16);
|
||||||
}];
|
}];
|
||||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.top.equalTo(self.topBar.mas_bottom).offset(12);
|
make.top.equalTo(self.topBar.mas_bottom).offset(12);
|
||||||
@@ -119,8 +120,8 @@ static NSString * const kResultCellId = @"KBSkinCardCell";
|
|||||||
CGFloat inset = 16; // 左右间距
|
CGFloat inset = 16; // 左右间距
|
||||||
CGFloat spacing = 12; // 列间距
|
CGFloat spacing = 12; // 列间距
|
||||||
CGFloat w = floor((width - inset * 2 - spacing) / 2.0);
|
CGFloat w = floor((width - inset * 2 - spacing) / 2.0);
|
||||||
CGFloat h = w * 0.75 + 8 + 20 + 10 + 6 + 8; // 与 KBSkinCardCell 估算一致
|
// CGFloat h = w * 0.75 + 8 + 20 + 10 + 6 + 8; // 与 KBSkinCardCell 估算一致
|
||||||
return CGSizeMake(w, h);
|
return CGSizeMake(w, KBFit(197));
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
|
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
|
||||||
|
|||||||
@@ -352,6 +352,7 @@ typedef NS_ENUM(NSInteger, KBSearchSection) {
|
|||||||
- (KBSearchBarView *)searchBarView {
|
- (KBSearchBarView *)searchBarView {
|
||||||
if (!_searchBarView) {
|
if (!_searchBarView) {
|
||||||
_searchBarView = [[KBSearchBarView alloc] init];
|
_searchBarView = [[KBSearchBarView alloc] init];
|
||||||
|
_searchBarView.bgCornerRadius = 18;
|
||||||
_searchBarView.placeholder = @"Themes";
|
_searchBarView.placeholder = @"Themes";
|
||||||
KBWeakSelf
|
KBWeakSelf
|
||||||
_searchBarView.onSearch = ^(NSString * _Nonnull keyword) {
|
_searchBarView.onSearch = ^(NSString * _Nonnull keyword) {
|
||||||
|
|||||||
Reference in New Issue
Block a user