찾다

 >  Q&A  >  본문

ios - iPhone, 为什么设置 navigation item 的alpha值会改变 self.view.frame?

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

<code>-(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;

        }

}

 

</code>

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

PHPzPHPz2892일 전305

모든 응답(2)나는 대답할 것이다

  • PHPz

    PHPz2017-04-18 09:09:40

    스크롤뷰 자동 적용을 끌 수 있습니다

    회신하다
    0
  • 迷茫

    迷茫2017-04-18 09:09:40

    많은 컨트롤의 속성 설정이 레이아웃을 트리거할 가능성이 있습니다.

    회신하다
    0
  • 취소회신하다