@@ -36,8 +36,7 @@ typedef enum {
3636 QMUINavigationButtonTypeNormal, // 普通导航栏文字按钮
3737 QMUINavigationButtonTypeBold, // 导航栏加粗按钮
3838 QMUINavigationButtonTypeImage, // 图标按钮
39- QMUINavigationButtonTypeBack, // 自定义返回按钮(可以同时带有title)
40- QMUINavigationButtonTypeClose, // 自定义关闭按钮(只显示icon不带title)
39+ QMUINavigationButtonTypeBack // 自定义返回按钮(可以同时带有title)
4140} QMUINavigationButtonType;
4241
4342typedef enum {
@@ -112,7 +111,11 @@ typedef NS_ENUM(NSInteger, QMUINavigationButtonPosition) {
112111
113112
114113/* *
115- * `QMUINavigationButton`是用于UINavigationBar的按钮
114+ * QMUINavigationButton 是用于 UINavigationItem 的按钮,有两种使用方式:
115+ * 1. 利用类方法,快速生成所需的 UIBarButtonItem,其中大部分 UIBarButtonItem 均使用系统的 initWithBarButtonSystemItem 或 initWithImage 接口创建,仅有返回按钮利用了 customView 来创建 UIBarButtonItem。
116+ * 2. 利用 init 方法生成一个 QMUINavigationButton 实例,再通过类方法 + barButtonItemWithNavigationButton:position:target:action: 来生成一个对应的 UIBarButtonItem,此时 QMUINavigationButton 将作为 UIBarButtonItem 的 customView。
117+ * 若能满足需求,建议优先使用第 1 种方式。
118+ * @note 关于 tintColor:UIBarButtonItem 如果使用了 customView,则需要修改 customView.tintColor,如果没使用 customView,则直接修改 UIBarButtonItem.tintColor。
116119 */
117120@interface QMUINavigationButton : UIButton
118121
@@ -146,34 +149,96 @@ typedef NS_ENUM(NSInteger, QMUINavigationButtonPosition) {
146149- (instancetype )initWithImage : (UIImage *)image ;
147150
148151/* *
149- * 创建一个返回按钮的UIBarButtonItem,默认使用没有tintColor的那个接口就好了。如果某些界面需要重新设置navBar的tintColor,则使用有tintColor的那个接口来兼容iOS6。
152+ * 创建一个 type 为 QMUINavigationButtonTypeBack 的 button 并作为 customView 用于生成一个 UIBarButtonItem,返回按钮的图片由配置表里的宏 NavBarBackIndicatorImage 决定。
153+ * @param target 按钮点击事件的接收者
154+ * @param selector 按钮点击事件的方法
155+ * @param tintColor 按钮要显示的颜色,如果为 nil,则表示跟随当前 UINavigationBar 的 tintColor
150156 */
151157+ (UIBarButtonItem *)backBarButtonItemWithTarget : (id )target action : (SEL )selector tintColor : (UIColor *)tintColor ;
158+
159+ /* *
160+ * 创建一个 type 为 QMUINavigationButtonTypeBack 的 button 并作为 customView 用于生成一个 UIBarButtonItem,返回按钮的图片由配置表里的宏 NavBarBackIndicatorImage 决定,按钮颜色跟随 UINavigationBar 的 tintColor。
161+ * @param target 按钮点击事件的接收者
162+ * @param selector 按钮点击事件的方法
163+ */
152164+ (UIBarButtonItem *)backBarButtonItemWithTarget : (id )target action : (SEL )selector ;
153165
154166/* *
155- * 创建一个关闭按钮的UIBarButtonItem,默认使用没有tintColor的那个接口就好了。如果某些界面需要重新设置navBar的tintColor,则使用有tintColor的那个接口来兼容iOS6。
167+ * 创建一个以 “×” 为图标的关闭按钮,图片由配置表里的宏 NavBarCloseButtonImage 决定。
168+ * @param target 按钮点击事件的接收者
169+ * @param selector 按钮点击事件的方法
170+ * @param tintColor 按钮要显示的颜色,如果为 nil,则表示跟随当前 UINavigationBar 的 tintColor
156171 */
157172+ (UIBarButtonItem *)closeBarButtonItemWithTarget : (id )target action : (SEL )selector tintColor : (UIColor *)tintColor ;
173+
174+ /* *
175+ * 创建一个以 “×” 为图标的关闭按钮,图片由配置表里的宏 NavBarCloseButtonImage 决定,图片颜色跟随 UINavigationBar.tintColor。
176+ * @param target 按钮点击事件的接收者
177+ * @param selector 按钮点击事件的方法
178+ */
158179+ (UIBarButtonItem *)closeBarButtonItemWithTarget : (id )target action : (SEL )selector ;
159180
160- /* *
161- * 创建一个特定type的UIBarButtonItem,默认使用没有tintColor的那个接口就好了。如果某些界面需要重新设置navBar的tintColor,则使用有tintColor的那个接口来兼容iOS6。
181+ /* *
182+ * 创建一个 UIBarButtonItem
183+ * @param type 按钮的类型
184+ * @param title 按钮的标题
185+ * @param tintColor 按钮的颜色,如果为 nil,则表示跟随当前 UINavigationBar 的 tintColor
186+ * @param position 按钮在 UINavigationBar 上的左右位置,如果某一边的按钮有多个,则只有最左边(最右边)的按钮需要设置为 QMUINavigationButtonPositionLeft(QMUINavigationButtonPositionRight),靠里的按钮使用 QMUINavigationButtonPositionNone 即可
187+ * @param target 按钮点击事件的接收者
188+ * @param selector 按钮点击事件的方法
162189 */
163190+ (UIBarButtonItem *)barButtonItemWithType : (QMUINavigationButtonType)type title : (NSString *)title tintColor : (UIColor *)tintColor position : (QMUINavigationButtonPosition)position target : (id )target action : (SEL )selector ;
191+
192+ /* *
193+ * 创建一个 UIBarButtonItem
194+ * @param type 按钮的类型
195+ * @param title 按钮的标题
196+ * @param position 按钮在 UINavigationBar 上的左右位置,如果某一边的按钮有多个,则只有最左边(最右边)的按钮需要设置为 QMUINavigationButtonPositionLeft(QMUINavigationButtonPositionRight),靠里的按钮使用 QMUINavigationButtonPositionNone 即可
197+ * @param target 按钮点击事件的接收者
198+ * @param selector 按钮点击事件的方法
199+ */
164200+ (UIBarButtonItem *)barButtonItemWithType : (QMUINavigationButtonType)type title : (NSString *)title position : (QMUINavigationButtonPosition)position target : (id )target action : (SEL )selector ;
165201
166202/* *
167- * 以customView的方式用`QMUINavigationButton`创建一个UIBarButtonItem。position、target、selector等参数不需要对button设置,通过参数传进来就可以了。
203+ * 将参数传进来的 button 作为 customView 用于生成一个 UIBarButtonItem。
204+ * @param button 要作为 customView 的 QMUINavigationButton
205+ * @param tintColor 按钮的颜色,如果为 nil,则表示跟随当前 UINavigationBar 的 tintColor
206+ * @param position 按钮在 UINavigationBar 上的左右位置,如果某一边的按钮有多个,则只有最左边(最右边)的按钮需要设置为 QMUINavigationButtonPositionLeft(QMUINavigationButtonPositionRight),靠里的按钮使用 QMUINavigationButtonPositionNone 即可
207+ * @param target 按钮点击事件的接收者
208+ * @param selector 按钮点击事件的方法
168209 *
169- * @warning 没有提供highLihgted和disabled的样式,需要在button自定义。
210+ * @note tintColor、position、target、selector 等参数不需要对 QMUINavigationButton 设置,通过参数传进来就可以了,就算设置了也会在这个方法里被覆盖。
211+ */
212+ + (UIBarButtonItem *)barButtonItemWithNavigationButton : (QMUINavigationButton *)button tintColor : (UIColor *)tintColor position : (QMUINavigationButtonPosition)position target : (id )target action : (SEL )selector ;
213+
214+ /* *
215+ * 将参数传进来的 button 作为 customView 用于生成一个 UIBarButtonItem。
216+ * @param button 要作为 customView 的 QMUINavigationButton
217+ * @param position 按钮在 UINavigationBar 上的左右位置,如果某一边的按钮有多个,则只有最左边(最右边)的按钮需要设置为 QMUINavigationButtonPositionLeft(QMUINavigationButtonPositionRight),靠里的按钮使用 QMUINavigationButtonPositionNone 即可
218+ * @param target 按钮点击事件的接收者
219+ * @param selector 按钮点击事件的方法
220+ *
221+ * @note position、target、selector 等参数不需要对 QMUINavigationButton 设置,通过参数传进来就可以了,就算设置了也会在这个方法里被覆盖。
170222 */
171223+ (UIBarButtonItem *)barButtonItemWithNavigationButton : (QMUINavigationButton *)button position : (QMUINavigationButtonPosition)position target : (id )target action : (SEL )selector ;
172224
173225/* *
174- * 创建一个图标类型的`UIBarButtonItem`
226+ * 创建一个图片类型的 UIBarButtonItem
227+ * @param image 按钮的图标
228+ * @param tintColor 按钮的颜色,如果为 nil,则表示跟随当前 UINavigationBar 的 tintColor
229+ * @param position 按钮在 UINavigationBar 上的左右位置,如果某一边的按钮有多个,则只有最左边(最右边)的按钮需要设置为 QMUINavigationButtonPositionLeft(QMUINavigationButtonPositionRight),靠里的按钮使用 QMUINavigationButtonPositionNone 即可
230+ * @param target 按钮点击事件的接收者
231+ * @param selector 按钮点击事件的方法
175232 */
176233+ (UIBarButtonItem *)barButtonItemWithImage : (UIImage *)image tintColor : (UIColor *)tintColor position : (QMUINavigationButtonPosition)position target : (id )target action : (SEL )selector ;
234+
235+ /* *
236+ * 创建一个图片类型的 UIBarButtonItem
237+ * @param image 按钮的图标
238+ * @param position 按钮在 UINavigationBar 上的左右位置,如果某一边的按钮有多个,则只有最左边(最右边)的按钮需要设置为 QMUINavigationButtonPositionLeft(QMUINavigationButtonPositionRight),靠里的按钮使用 QMUINavigationButtonPositionNone 即可
239+ * @param target 按钮点击事件的接收者
240+ * @param selector 按钮点击事件的方法
241+ */
177242+ (UIBarButtonItem *)barButtonItemWithImage : (UIImage *)image position : (QMUINavigationButtonPosition)position target : (id )target action : (SEL )selector ;
178243
179244/* *
0 commit comments