Navigation Bar Rightbaritem Image-Button Bug iOS 11

navigation bar rightbaritem image-button bug iOS 11

Reason

The problem appears because from ios 11 UIBarButtonItem uses autolayout instead of dealing with frames.

Solution

You should add width constraint for this image-button if you use Xcode 9.

 button.widthAnchor.constraint(equalToConstant: 32.0).isActive = true
button.heightAnchor.constraint(equalToConstant: 32.0).isActive = true

PS

button is not UIBarButtonItem, it is UIButton inside UIBarButtonItem. You should set constraint not for UIBarButtonItem, but for elements inside it.

iOS 11 navigation bar / uibarbutton items rendering issues

refer to UIBarButtonItem on iOS 11

UIBarButtonItem uses autolayout instead of dealing with frames.

That's why the button is got stretched .

Modify:

widthConstraint = leftBackBtn.WidthAnchor.ConstraintEqualTo(27);
heightConstraint = leftBackBtn.HeightAnchor.ConstraintEqualTo(20);
widthConstraint.Active = true;
heightConstraint.Active = true;

Navigation bar custom image view issue in iOS 11

This types of issue faced by many developers because of in iOS 11 UIBarButtonItem uses auto-layout instead of frames.

So you just want to set profile image on top right barButton items then please check my answer..

Other wise you can add constraints of imageView in you code like below

    let widthConstraint = imageView.widthAnchor.constraint(equalToConstant: 34)
let heightConstraint = imageView.heightAnchor.constraint(equalToConstant: 34)
heightConstraint.isActive = true
widthConstraint.isActive = true

iOS 11 leftBarButtonItem/rightBarButtonItem location bug

It looks like your problem is caused by the search bar being bigger rather than something in the buttons.

You may want to try something like:

if #available(iOS 11.0, *) {
[[self.yourSearchBar.heightAnchor constraintEqualToConstant:44.0] setActive:YES]
}

Or investigate and implement the iOS 11 search bar changes.

Back button in navigation bar not getting tapped in ios 11

Overriding the following method in my custom UIView class did the trick for me:

override var intrinsicContentSize: CGSize {
return UILayoutFittingExpandedSize
}


Related Topics



Leave a reply



Submit