UINavigationBar

#import 
#import 
#import 
#import 
#import 
#import 
#import 
#import 

导入某个框架的某个头文件,说明在这里面需要用到

NS_ASSUME_NONNULL_BEGIN

@class UINavigationItem, UIBarButtonItem, UIImage, UIColor;
// 引入其他类,或者协议,需要用到的
@protocol UINavigationBarDelegate;

NS_CLASS_AVAILABLE_IOS(2_0) @interface UINavigationBar : UIView  

@property(nonatomic,assign) UIBarStyle barStyle UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;
@property(nullable,nonatomic,weak) id delegate;

/*
 New behavior on iOS 7.
 Default is YES.
 You may force an opaque background by setting the property to NO.
 If the navigation bar has a custom background image, the default is inferred 
 from the alpha values of the image—YES if it has any pixel with alpha < 1.0
 If you send setTranslucent:YES to a bar with an opaque custom background image
 it will apply a system opacity less than 1.0 to the image.
 If you send setTranslucent:NO to a bar with a translucent custom background image
 it will provide an opaque background for the image using the bar's barTintColor if defined, or black
 for UIBarStyleBlack or white for UIBarStyleDefault if barTintColor is nil.

  iOS 7新添加的行为。
  默认为YES。
  您可以通过将属性设置为NO来强制使用不透明背景。
被动设置:
  1.如果导航栏设置了自定义背景图像,则会推断出该属性的默认值从图像的alpha值
  如果图像中有alpha <1.0的任何像素,则开始该属性被设置为YES,
- 释义:如果导航栏设置了一张自定义图片,那么只要这个图片中,有一个像素点透明度小于1,那么该属性将被设置为YES,即半透明。
主动设置:
 2.  如果您通过 ”setTranslucent:YES “方法将导航栏设置为半透明,并且这个导航栏已经设置了一张不透明背景图像,
  它会将小于1.0的系统不透明度应用于图像。
- 释义:如果你将该属性设为YES,并且这个导航栏已经设置了一张不透明的背景图片(即图片中的每一个像素点的alpha值,都为1),那么该背景图片的透明杜,即alpha将会小于1,被随机设置为一个系统的不透明度。
  3.如果您通过setTranslucent:NO方法将导航栏设置为不透明,并且这个导航栏已经设置了一张半透明背景图像,
  它将使用条形图的barTintColor(如果已定义)或黑色为图像提供不透明背景
  如果barTintColor为nil,则为UIBarStyleBlack或白色为UIBarStyleDefault。
- 释义:一旦设置为NO,就是不透明

总结:如果是被动设置,如果图片的alpha小于< 1,那么该属性值就是YES,除非是1,值为NO,
如果是主动设置,不管设置的背景图片的alpha是否为1,如果该属性值为YES, 那么导航栏就是半透明,如果该属性值为NO,那么导航栏为YES。
 */
//  半透明
@property(nonatomic,assign,getter=isTranslucent) BOOL translucent  NS_AVAILABLE_IOS(3_0) UI_APPEARANCE_SELECTOR; // Default is NO on iOS 6 and earlier. Always YES if barStyle is set to UIBarStyleBlackTranslucent
// iOS 6及更早版本的默认值为NO。 如果barStyle设置为UIBarStyleBlackTranslucent,则始终为YES


// Pushing a navigation item displays the item's title in the center of the navigation bar.
// The previous top navigation item (if it exists) is displayed as a "back" button on the left.
- (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated;
- (nullable UINavigationItem *)popNavigationItemAnimated:(BOOL)animated; // Returns the item that was popped.

@property(nullable, nonatomic,readonly,strong) UINavigationItem *topItem;
@property(nullable, nonatomic,readonly,strong) UINavigationItem *backItem;

@property(nullable,nonatomic,copy) NSArray *items;
- (void)setItems:(nullable NSArray *)items animated:(BOOL)animated; // If animated is YES, then simulate a push or pop depending on whether the new top item was previously in the stack.
// 如果动画为YES,则根据新的顶级项目是否先前位于堆栈中来模拟push或pop。

/// When set to YES, the navigation bar will use a larger out-of-line title view when requested by the current navigation item. To specify when the large out-of-line title view appears, see UINavigationItem.largeTitleDisplayMode. Defaults to NO.
// 设置为YES时,导航栏将在当前导航项请求时使用更大的外线标题视图。 要指定何时显示大的外部标题视图,请参阅UINavigationItem.largeTitleDisplayMode。 默认为NO。

@property (nonatomic, readwrite, assign) BOOL prefersLargeTitles UI_APPEARANCE_SELECTOR API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos);

/*
 The behavior of tintColor for bars has changed on iOS 7.0. It no longer affects the bar's background
 and behaves as described for the tintColor property added to UIView.
 To tint the bar's background, please use -barTintColor.
在iOS 7.0上,tintColor对导航栏的行为已经改变。 它不再影响导航栏的背景
  行为与添加到UIView的tintColor属性的描述相同。
  要为导航栏的背景着色,请使用-barTintColor。

 */
@property(null_resettable, nonatomic,strong) UIColor *tintColor;
@property(nullable, nonatomic,strong) UIColor *barTintColor NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;  // default is nil

/* In general, you should specify a value for the normal state to be used by other states which don't have a custom value set.
 
 Similarly, when a property is dependent on the bar metrics (on the iPhone in landscape orientation, bars have a different height from standard), be sure to specify a value for UIBarMetricsDefault.
通常,您应该为没有自定义值集的其他状态指定正常状态的值。
 
  同样,当属性依赖于条形度量标准时(在横向方向上的iPhone上,条形图与标准高度不同),请确保为UIBarMetricsDefault指定值。

 */

- (void)setBackgroundImage:(nullable UIImage *)backgroundImage forBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;
- (nullable UIImage *)backgroundImageForBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;

/*
Same as using UIBarPositionAny in -setBackgroundImage:forBarPosition:barMetrics. Resizable images will be stretched
vertically if necessary when the navigation bar is in the position UIBarPositionTopAttached.
与在-setBackgroundImage中使用UIBarPositionAny相同:forBarPosition:barMetrics。 可调整大小的图像将被拉伸
如果需要,当导航栏位于UIBarPositionTopAttached位置时垂直。
*/
- (void)setBackgroundImage:(nullable UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
- (nullable UIImage *)backgroundImageForBarMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;

/* Default is nil. When non-nil, a custom shadow image to show instead of the default shadow image. For a custom shadow to be shown, a custom background image must also be set with -setBackgroundImage:forBarMetrics: (if the default background image is used, the default shadow image will be used).
默认值为零。 当非零时,显示自定义阴影图像而不是默认阴影图像。 要显示自定义阴影,还必须使用-setBackgroundImage设置自定义背景图像:forBarMetrics :(如果使用默认背景图像,将使用默认阴影图像)。
 */
@property(nullable, nonatomic,strong) UIImage *shadowImage NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;

/* You may specify the font, text color, and shadow properties for the title in the text attributes dictionary, using the keys found in NSAttributedString.h.

您可以使用NSAttributedString.h中的键在文本属性字典中指定标题的字体,文本颜色和阴影属性。
 */
@property(nullable,nonatomic,copy) NSDictionary *titleTextAttributes NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;

/* You may specify the font, text color, and shadow properties for the large title in the text attributes dictionary, using the keys found in NSAttributedString.h.
 */
@property(nullable, nonatomic, copy) NSDictionary *largeTitleTextAttributes UI_APPEARANCE_SELECTOR API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos);

- (void)setTitleVerticalPositionAdjustment:(CGFloat)adjustment forBarMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
- (CGFloat)titleVerticalPositionAdjustmentForBarMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;

/*
 The back indicator image is shown beside the back button.
 The back indicator transition mask image is used as a mask for content during push and pop transitions
 Note: These properties must both be set if you want to customize the back indicator image.

后退指示图像显示在后退按钮旁边。
  后指示符转换掩码图像在推送和弹出转换期间用作内容的掩码
  注意:如果要自定义后指示图像,则必须同时设置这些属性。

 */
@property(nullable,nonatomic,strong) UIImage *backIndicatorImage NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;
@property(nullable,nonatomic,strong) UIImage *backIndicatorTransitionMaskImage NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;

@end

@protocol UINavigationBarDelegate 

@optional

- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPushItem:(UINavigationItem *)item; // called to push. return NO not to.
- (void)navigationBar:(UINavigationBar *)navigationBar didPushItem:(UINavigationItem *)item;    // called at end of animation of push or immediately if not animated
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item;  // same as push methods
- (void)navigationBar:(UINavigationBar *)navigationBar didPopItem:(UINavigationItem *)item;

@end

NS_ASSUME_NONNULL_END

#else
#import 
#endif

你可能感兴趣的:(UINavigationBar)