添加箭头
This commit is contained in:
21
keyBoard/Assets.xcassets/Home/home_down_arrow.imageset/Contents.json
vendored
Normal file
21
keyBoard/Assets.xcassets/Home/home_down_arrow.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "home_down_arrow.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
keyBoard/Assets.xcassets/Home/home_down_arrow.imageset/home_down_arrow.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/Home/home_down_arrow.imageset/home_down_arrow.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 852 B |
21
keyBoard/Assets.xcassets/Home/home_up_arrow.imageset/Contents.json
vendored
Normal file
21
keyBoard/Assets.xcassets/Home/home_up_arrow.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "home_up_arrow.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
keyBoard/Assets.xcassets/Home/home_up_arrow.imageset/home_up_arrow.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/Home/home_up_arrow.imageset/home_up_arrow.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 773 B |
@@ -29,9 +29,15 @@
|
||||
@property (nonatomic, strong) UIButton *hotButton;
|
||||
@property (nonatomic, strong) UIButton *rankButton;
|
||||
@property (nonatomic, strong) UIImageView *underlineImageView; // 选中下划线
|
||||
/// 顶部拖拽方向图标(初始向上,展开至顶部后向下)
|
||||
@property (nonatomic, strong) UIImageView *dragArrowImageView;
|
||||
|
||||
// 承载子控制器内容
|
||||
@property (nonatomic, strong) UIView *containerView;
|
||||
// 注意:父类 HWPanModalContentView 内部已有名为 `containerView` 的属性(类型为 HWPanModalContainerView),
|
||||
// 不能同名,否则会导致运行时通过该属性访问到我们自己的 UIView,从而在库里调用
|
||||
// `currentPresentationState` 时崩溃(- [UIView currentPresentationState] unrecognized selector)。
|
||||
// 因此这里将承载子内容的视图命名为 contentContainerView。
|
||||
@property (nonatomic, strong) UIView *contentContainerView;
|
||||
@property (nonatomic, strong) UIViewController *currentChild;
|
||||
@property (nonatomic, strong) HomeHotVC *hotVC;
|
||||
@property (nonatomic, strong) HomeRankVC *rankVC;
|
||||
@@ -73,21 +79,14 @@
|
||||
return _indicator;
|
||||
}
|
||||
|
||||
//- (void)panModalTransitionDidFinish {
|
||||
// // 初次展示后按当前状态设定一次朝向
|
||||
// [self.indicator applyPresentationState:self.hw_presentationState];
|
||||
// // 避免出现内容随弹窗上移的“位移动画”观感:
|
||||
// // 顶部栏在展示动画期间先隐藏,待完成后淡入
|
||||
// if (self.topBar && self.topBar.alpha < 1.0) {
|
||||
// [UIView animateWithDuration:0.18 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
|
||||
// self.topBar.alpha = 1.0;
|
||||
// } completion:nil];
|
||||
// }
|
||||
//}
|
||||
// 弹窗展示动画完成:根据当前展示状态设置一次箭头图
|
||||
- (void)panModalTransitionDidFinish {
|
||||
[self kb_updateDragArrowForState:self.hw_presentationState];
|
||||
}
|
||||
|
||||
- (void)didChangeTransitionToState:(PresentationState)state {
|
||||
// // 每次状态切换完成后刷新朝向
|
||||
// [self.indicator applyPresentationState:state];
|
||||
// 每次状态切换完成后刷新顶部箭头
|
||||
[self kb_updateDragArrowForState:state];
|
||||
}
|
||||
|
||||
- (PanModalHeight)shortFormHeight {
|
||||
@@ -191,7 +190,9 @@
|
||||
|
||||
// 顶部栏
|
||||
[self.secWhiteContentView addSubview:self.topBar];
|
||||
[self.secWhiteContentView addSubview:self.containerView];
|
||||
[self.secWhiteContentView addSubview:self.contentContainerView];
|
||||
// 顶部拖拽方向箭头(放在顶部栏之上)
|
||||
[self addSubview:self.dragArrowImageView];
|
||||
|
||||
// 调整层级:将人物与皇冠图放到左右背景图的后面(z 轴更低)
|
||||
[self.secWhiteContentView insertSubview:self.personImageView belowSubview:self.leftBgImageView];
|
||||
@@ -238,6 +239,14 @@
|
||||
make.top.equalTo(self.secWhiteContentView).offset(topPadding);
|
||||
make.height.mas_equalTo(54);
|
||||
}];
|
||||
|
||||
// 将箭头放在顶部栏上方,居中显示
|
||||
[self.dragArrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self.topBar);
|
||||
make.bottom.equalTo(self.topBar.mas_top).offset(-20);
|
||||
make.width.mas_equalTo(18);
|
||||
make.height.mas_equalTo(18);
|
||||
}];
|
||||
|
||||
[self.hotButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.equalTo(self.topBar).offset(3);
|
||||
@@ -258,7 +267,7 @@
|
||||
make.width.mas_equalTo(78);
|
||||
}];
|
||||
|
||||
[self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
[self.contentContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.topBar.mas_bottom).offset(8);
|
||||
make.left.right.equalTo(self.secWhiteContentView).inset(20);
|
||||
make.bottom.equalTo(self.secWhiteContentView);
|
||||
@@ -318,10 +327,10 @@
|
||||
|
||||
// 添加目标
|
||||
// [self addChildViewController:target];
|
||||
[self.containerView addSubview:target.view];
|
||||
[self.contentContainerView addSubview:target.view];
|
||||
[target.view mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.top.right.equalTo(self.containerView);
|
||||
make.bottom.equalTo(self.containerView).offset(-KB_TABBAR_HEIGHT);
|
||||
make.left.top.right.equalTo(self.contentContainerView);
|
||||
make.bottom.equalTo(self.contentContainerView).offset(-KB_TABBAR_HEIGHT);
|
||||
}];
|
||||
// [target didMoveToParentViewController:self];
|
||||
self.currentChild = target;
|
||||
@@ -414,11 +423,11 @@
|
||||
return _topBar;
|
||||
}
|
||||
|
||||
- (UIView *)containerView{
|
||||
if (!_containerView) {
|
||||
_containerView = [[UIView alloc] init];
|
||||
- (UIView *)contentContainerView{
|
||||
if (!_contentContainerView) {
|
||||
_contentContainerView = [[UIView alloc] init];
|
||||
}
|
||||
return _containerView;
|
||||
return _contentContainerView;
|
||||
}
|
||||
|
||||
- (UIImageView *)underlineImageView{
|
||||
@@ -429,6 +438,32 @@
|
||||
return _underlineImageView;
|
||||
}
|
||||
|
||||
// 顶部拖拽方向箭头
|
||||
- (UIImageView *)dragArrowImageView {
|
||||
if (!_dragArrowImageView) {
|
||||
_dragArrowImageView = [[UIImageView alloc] init];
|
||||
_dragArrowImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
// 初始在 Short 状态,显示向上的箭头
|
||||
_dragArrowImageView.image = [UIImage imageNamed:@"home_up_arrow"];
|
||||
}
|
||||
return _dragArrowImageView;
|
||||
}
|
||||
|
||||
// 根据弹窗展示状态切换箭头图
|
||||
- (void)kb_updateDragArrowForState:(PresentationState)state {
|
||||
NSString *imgName = (state == PresentationStateMedium) ? @"home_down_arrow" : @"home_up_arrow";
|
||||
UIImage *img = [UIImage imageNamed:imgName];
|
||||
if (img && self.dragArrowImageView.image != img) {
|
||||
// 柔和切换,避免频繁拖拽时突兀
|
||||
[UIView transitionWithView:self.dragArrowImageView
|
||||
duration:0.18
|
||||
options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionBeginFromCurrentState
|
||||
animations:^{
|
||||
self.dragArrowImageView.image = img;
|
||||
} completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (UIImageView *)leftBgImageView{
|
||||
if (!_leftBgImageView) {
|
||||
|
||||
Reference in New Issue
Block a user