iOS 11 UIBarButtonItem images not sizing

后端 未结 2 1703
暗喜
暗喜 2020-12-03 14:30

The answer to my question was hinted at in this question, so I think the answer is to disable autolayout for my UIToolbar view.

The code that is said to work for vi

2条回答
  •  -上瘾入骨i
    2020-12-03 15:15

    BarButtonItem (iOS11\xCode9) uses autolayout instead of frames. Try this (Swift):

    if #available(iOS 9.0, *) {
        cButton.widthAnchor.constraint(equalToConstant: customViewButton.width).isActive = true
        cButton.heightAnchor.constraint(equalToConstant: customViewButton.height).isActive = true
    }
    

    Objective C

    if (@available(iOS 9, *)) {
         [cButton.widthAnchor constraintEqualToConstant: standardButtonSize.width].active = YES;
         [cButton.heightAnchor constraintEqualToConstant: standardButtonSize.height].active = YES;
    }
    

提交回复
热议问题