iOS 11 navigationItem.titleView Width Not Set

后端 未结 14 1727
遥遥无期
遥遥无期 2020-12-13 07:58

Seeing a behavior on iOS11 with a navigationItem.titleView where the width of the titleView is not the full width of the screen.

I have a custom view that I set as t

14条回答
  •  春和景丽
    2020-12-13 08:53

    return UILayoutFittingExpandedSize not helped me, because view was added vertically few more times to fill layout.

    The solution was to override intrinsicContentSize in custom view setting width to max screen width:

     - (CGSize)intrinsicContentSize {
        //fills empty space. View will be resized to be smaller, but if it is too small - then it stays too small
        CGRect frame = self.frame;
        frame.size.width = MAX(SCREEN_WIDTH, SCREEN_HEIGHT);
        return frame.size;
    }
    

提交回复
热议问题