ios - iPhone, 为什么设置 navigation item 的alpha值会改变 self.view.frame?
PHPz
PHPz 2017-04-18 09:07:40
[iOS讨论组]

我使用了一个UIPanGestureRecognizer,在UIPanGestureRecognizer的滚动事件selector中,我需要不断的去改变navigation item的alpha值.代码入下:

-(void)scrollSlideView:(UIPanGestureRecognizer *) panGesture{
[self hideTopview:self.slideMultiViewController.view.frame.origin.y];
}
-(void)hideTopview:(CGFloat) alpha{

    alpha = (alpha - 64)/100;
    float adjustAlpha;
    if (alpha < 0) {
        alpha = 0;
    }
    if (alpha < 0.5) {
        self.navigationItem.rightBarButtonItem = self.rightBarItemSmall;
        self.navigationItem.titleView = self.naviShopName;
        self.naviShopName.frame = CGRectMake(0, 0, 200, 30);
        self.naviShopName.alpha =0;
        self.naviRightViewSmall.alpha = 0;
        
        adjustAlpha = (alpha)/0.5;
        self.naviShopName.alpha =1 - adjustAlpha;
        self.naviRightViewSmall.alpha = 1 - adjustAlpha;
        
    }
    if(alpha > 0.5){
        self.navigationItem.rightBarButtonItem = self.rightBarItemFull;
        self.navigationItem.titleView = nil;
        if (alpha>1) {
            adjustAlpha = 1;
        }
        else{
            adjustAlpha = (alpha - 0.5)/0.5;
            }
            self.naviRightViewFull.alpha = adjustAlpha;
        }
}

最初我的view.frame.height = 668,但是执行hideTopview以后,view.frame.height = 568,请问这是怎么回事呢?

PHPz
PHPz

学习是最好的投资!

全部回复(2)
PHPz

可以尝试关闭scrollview的自动适配

迷茫

很可能触发了布局,很多控件的属性设置有可能触发布局。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号