【UIKit】-13-UIBarButtonItem - barButton

本文详细介绍了UIBarButtonItem的概念及使用方法,包括其继承关系、初始化方法、样式设置等,并提供了多种初始化示例,如图片、标题、系统图标等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



http://blog.youkuaiyun.com/sirchenhua/article/details/7299932
http://blog.youkuaiyun.com/kmyhy/article/details/7174162
http://www.2cto.com/kf/201305/208473.html

暂无实例,待修改
A bar button item is a button specialized for placement on a UIToolbar or UINavigationBar object. It inherits basic button behavior from its abstract superclass, UIBarItem. The UIBarButtonItem defines additional initialization methods and properties for use on toolbars and navigation bars. You typically use Interface Builder to create and configure bar button items.

酒吧按钮项是专门用于放置一个UIToolbar或UINavigationBar的对象上的按钮。它继承自它的抽象父类,UIBarItem基本按钮的行为。该定义的UIBarButtonItem额外的初始化的方法和属性上的工具栏和导航栏使用。您通常使用Interface Builder来创建和配置栏按钮的项目。


 

#import <CoreGraphics/CoreGraphics.h>

#import <Foundation/Foundation.h>

#import <UIKit/UIBarItem.h>

#import <UIKit/UIKitDefines.h>

#import <UIKit/UIAppearance.h>

#import <UIKit/UIApplication.h>

#import <UIKit/UIBarCommon.h>

 

typedef NS_ENUM(NSInteger,UIBarButtonItemStyle) {

   UIBarButtonItemStylePlain,

   UIBarButtonItemStyleBordered NS_ENUM_DEPRECATED_IOS(2_0,8_0, "UseUIBarButtonItemStylePlain when minimum deployment target is iOS7 or later"),

   UIBarButtonItemStyleDone,

};

 

typedef NS_ENUM(NSInteger,UIBarButtonSystemItem) {

   UIBarButtonSystemItemDone,

   UIBarButtonSystemItemCancel,

    UIBarButtonSystemItemEdit, 

   UIBarButtonSystemItemSave, 

   UIBarButtonSystemItemAdd,

   UIBarButtonSystemItemFlexibleSpace,

   UIBarButtonSystemItemFixedSpace,

   UIBarButtonSystemItemCompose,

   UIBarButtonSystemItemReply,

   UIBarButtonSystemItemAction,

   UIBarButtonSystemItemOrganize,

   UIBarButtonSystemItemBookmarks,

   UIBarButtonSystemItemSearch,

   UIBarButtonSystemItemRefresh,

   UIBarButtonSystemItemStop,

   UIBarButtonSystemItemCamera,

   UIBarButtonSystemItemTrash,

   UIBarButtonSystemItemPlay,

   UIBarButtonSystemItemPause,

   UIBarButtonSystemItemRewind,

   UIBarButtonSystemItemFastForward,

#if __IPHONE_3_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED

   UIBarButtonSystemItemUndo,

   UIBarButtonSystemItemRedo,

#endif

#if __IPHONE_4_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED

   UIBarButtonSystemItemPageCurl,

#endif

};

 

@class UIImageUIView;

 

NS_CLASS_AVAILABLE_IOS(2_0)@interface UIBarButtonItem: UIBarItem <NSCoding> {

  @private

    NSString     *_title;

    NSSet        *_possibleTitles;

    SEL           _action;

    id            _target;

    UIImage      *_image;

    UIImage      *_landscapeImagePhone;

    UIEdgeInsets  _imageInsets;

    UIEdgeInsets  _landscapeImagePhoneInsets;

    CGFloat       _width;  

    UIView       *_view;

    NSInteger     _tag;

    id            _appearanceStorage;

    struct {

        unsigned int enabled:1;

        unsigned int style:3;

        unsigned int isSystemItem:1;

        unsigned int systemItem:7;

        unsigned int viewIsCustom:1;

        unsigned int isMinibarView:1;

        unsigned intdisableAutosizing:1;

        unsigned int selected:1;

        unsigned int imageHasEffects:1;

    }_barButtonItemFlags;

}

 

- (instancetype)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action;

- (instancetype)initWithImage:(UIImage *)image landscapeImagePhone:(UIImage *)landscapeImagePhone style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)actionNS_AVAILABLE_IOS(5_0);

- (instancetype)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action;

- (instancetype)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItemtarget:(id)targetaction:(SEL)action;

- (instancetype)initWithCustomView:(UIView *)customView;

 

@property(nonatomic)        UIBarButtonItemStyle style;            // default is UIBarButtonItemStylePlain

@property(nonatomic)        CGFloat             width;            // default is 0.0

@property(nonatomic,copy)   NSSet              *possibleTitles;   // default is nil

@property(nonatomic,retainUIView             *customView;       // default is nil

@property(nonatomic)        SEL                  action;           // default is NULL

@property(nonatomic,assignid                  target;           // default is nil

 

- (void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)statebarMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;

- (UIImage *)backgroundImageForState:(UIControlState)state barMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;


- (void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)statestyle:(UIBarButtonItemStyle)style barMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;

- (UIImage *)backgroundImageForState:(UIControlState)state style:(UIBarButtonItemStyle)style barMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(6_0)UI_APPEARANCE_SELECTOR;

 

@property(nonatomic,retain)UIColor *tintColor NS_AVAILABLE_IOS(5_0);


- (void)setBackgroundVerticalPositionAdjustment:(CGFloat)adjustmentforBarMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;

- (CGFloat)backgroundVerticalPositionAdjustmentForBarMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;

 

- (void)setTitlePositionAdjustment:(UIOffset)adjustment forBarMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;

- (UIOffset)titlePositionAdjustmentForBarMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;


- (void)setBackButtonBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)statebarMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;

- (UIImage *)backButtonBackgroundImageForState:(UIControlState)statebarMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;

 

- (void)setBackButtonTitlePositionAdjustment:(UIOffset)adjustmentforBarMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;

- (UIOffset)backButtonTitlePositionAdjustmentForBarMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;

 

- (void)setBackButtonBackgroundVerticalPositionAdjustment:(CGFloat)adjustmentforBarMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;

- (CGFloat)backButtonBackgroundVerticalPositionAdjustmentForBarMetrics:(UIBarMetrics)barMetricsNS_AVAILABLE_IOS(5_0)UI_APPEARANCE_SELECTOR;

 

@end

 

 



一、综合实战—使用极轴追踪方式绘制信号灯 实战目标:利用对象捕捉追踪和极轴追踪功能创建信号灯图形 技术要点:结合两种追踪方式实现精确绘图,适用于工程制图中需要精确定位的场景 1. 切换至AutoCAD 操作步骤: 启动AutoCAD 2016软件 打开随书光盘中的素材文件 确认工作空间为"草图与注释"模式 2. 绘图设置 1)草图设置对话框 打开方式:通过"工具→绘图设置"菜单命令 功能定位:该对话框包含捕捉、追踪等核心绘图辅助功能设置 2)对象捕捉设置 关键配置: 启用对象捕捉(F3快捷键) 启用对象捕捉追踪(F11快捷键) 勾选端点、中心、圆心、象限点等常用捕捉模式 追踪原理:命令执行时悬停光标可显示追踪矢量,再次悬停可停止追踪 3)极轴追踪设置 参数设置: 启用极轴追踪功能 设置角度增量为45度 确认后退出对话框 3. 绘制信号灯 1)绘制圆形 执行命令:"绘图→圆→圆心、半径"命令 绘制过程: 使用对象捕捉追踪定位矩形中心作为圆心 输入半径值30并按Enter确认 通过象限点捕捉确保圆形位置准确 2)绘制直线 操作要点: 选择"绘图→直线"命令 捕捉矩形上边中点作为起点 捕捉圆的上象限点作为终点 按Enter结束当前直线命令 重复技巧: 按Enter可重复最近使用的直线命令 通过圆心捕捉和极轴追踪绘制放射状直线 最终形成完整的信号灯指示图案 3)完成绘制 验证要点: 检查所有直线是否准确连接圆心和象限点 确认极轴追踪的45度增量是否体现 保存绘图文件(快捷键Ctrl+S)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值