PTBarButtonItemCustomView

@interface PTBarButtonItemCustomView : UIView

@property (nonatomic, strong, nullable) UIView *contentView;

@property (nonatomic, strong) PTBadgeIndicatorView *badgeIndicatorView;

- (instancetype)initWithContentView:(UIView *)contentView NS_DESIGNATED_INITIALIZER;

- (instancetype)initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER;

- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;

/**
 * Whether this view's left and/or right layout margins are removed when the left and/or right edge
 * of the view is aligned to its superview's edge(s).
 *
 * This is needed when used inside a `UIToolbar` or `UINavigationBar` because for custom views of a
 * `UIBarButtonItem` at the leading or trailing end of the bar, the bar's layout margin for that end
 * is not adjusted. For a `UIBarButtonItem` at the end of a bar without a custom view, the bar's
 * layout margin will be adjusted to align the button's image or title (*not* the button's layout margin)
 * with the bar's layout margin.
 *
 * The default value of this property is `YES`.
 */
@property (nonatomic, assign) BOOL adjustsLayoutMarginsForSuperview;

/**
 * Whether this view matches the full height of its superview, instead of the height of its
 * superview's `layoutMarginsGuide`.
 *
 * This is needed when used as the custom view of a `UIBarButtonItem` on iOS 26 and later,
 * where UIKit's enclosing bar button container has vertical layout margins. Matching the
 * guide there would collapse the view, rendering it smaller than, and below, the bar's
 * other items. Before iOS 26 the container had no vertical layout margins, so this property
 * has no effect on those versions.
 *
 * The default value of this property is `YES`. Set it to `NO` when the view is not the
 * custom view of a `UIBarButtonItem`.
 */
@property (nonatomic, assign) BOOL matchesSuperviewHeight;

@end

Undocumented

  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) UIView *contentView

    Swift

    var contentView: UIView? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, strong) PTBadgeIndicatorView *badgeIndicatorView

    Swift

    var badgeIndicatorView: PTBadgeIndicatorView { get set }
  • Undocumented

    Declaration

    Objective-C

    - (instancetype)initWithContentView:(UIView *)contentView NS_DESIGNATED_INITIALIZER;

    Swift

    init(contentView: UIView)
  • Undocumented

    Declaration

    Objective-C

    - (instancetype)initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER;

    Swift

    init(frame: CGRect)
  • Undocumented

    Declaration

    Objective-C

    - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;

    Swift

    init?(coder: NSCoder)
  • Whether this view’s left and/or right layout margins are removed when the left and/or right edge of the view is aligned to its superview’s edge(s).

    This is needed when used inside a UIToolbar or UINavigationBar because for custom views of a UIBarButtonItem at the leading or trailing end of the bar, the bar’s layout margin for that end is not adjusted. For a UIBarButtonItem at the end of a bar without a custom view, the bar’s layout margin will be adjusted to align the button’s image or title (not the button’s layout margin) with the bar’s layout margin.

    The default value of this property is YES.

    Declaration

    Objective-C

    @property (nonatomic) BOOL adjustsLayoutMarginsForSuperview;

    Swift

    var adjustsLayoutMarginsForSuperview: Bool { get set }
  • Whether this view matches the full height of its superview, instead of the height of its superview’s layoutMarginsGuide.

    This is needed when used as the custom view of a UIBarButtonItem on iOS 26 and later, where UIKit’s enclosing bar button container has vertical layout margins. Matching the guide there would collapse the view, rendering it smaller than, and below, the bar’s other items. Before iOS 26 the container had no vertical layout margins, so this property has no effect on those versions.

    The default value of this property is YES. Set it to NO when the view is not the custom view of a UIBarButtonItem.

    Declaration

    Objective-C

    @property (nonatomic) BOOL matchesSuperviewHeight;

    Swift

    var matchesSuperviewHeight: Bool { get set }