一 : 关于tableView 和 tableViewCell
1 加载 xib 需要需要调用的方法
需要调用一下的方法:
[tableV registerNib:
[UINib nibWithNibName:KMemberCell bundle:nil]
forCellReuseIdentifier:KMemberCell];
其中: tableView 的类方法 reginsterNib:(xib的文件名) forCellReuseIdentifier(cell的身份名)
2 关于 tableViewCell 的几个常用的属性
1 单元格的分割线
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
2 单元格的附加类型
typedef NS_ENUM(NSInteger, UITableViewCellAccessoryType) {
UITableViewCellAccessoryNone, // don't show any accessory view
UITableViewCellAccessoryDisclosureIndicator, // regular chevron. doesn't track
UITableViewCellAccessoryDetailDisclosureButton __TVOS_PROHIBITED, // info button w/ chevron. tracks
UITableViewCellAccessoryCheckmark, // checkmark. doesn't track
UITableViewCellAccessoryDetailButton NS_ENUM_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED // info button. tracks
};
cell.accessoryType = UITableViewCellAccessoryCheckmark
3 点击单元格时的 几种样式 (就是会不会有阴影出现)
typedef NS_ENUM(NSInteger, UITableViewCellSelectionStyle) {
UITableViewCellSelectionStyleNone,
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray,
UITableViewCellSelectionStyleDefault NS_ENUM_AVAILABLE_IOS(7_0)
};
共有四种枚举
cell.selectionStyle = UITableViewCellSelectionStyleNone
二 在导航栏左右添加按钮
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
主要调用的是这个方法 其中rightButton 是你自己定义的按钮
关于导航栏 我的理解 它有三个比较关键的类
1 navigationController 导航栏控制器
2 navigationBar 导航栏
通过导航栏 你可对你的导航栏进行自定义的设置 根据你的需求进行个性化定制
(1) 定制导航栏的高度
UINavigationBar *bar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 80)];
当然 导航栏的默认高度是64
(2)设置导航栏是否为透明
@property(nonatomic,assign,getter=isTranslucent)
BOOL
translucent;
(3)设置导航栏左右侧按钮的颜色 包括字体颜色和默认的图片颜色
@property(null_resettable, nonatomic,strong) UIColor *tintColor;
(4)设置导航栏字体的背景颜色
@property(nullable, nonatomic,strong) UIColor *barTintColor;
(5)设置导航栏的背景颜色
(
void
)setBackgroundImage:(nullable UIImage *)backgroundImage
(6) 中间字体的颜色
@property(nullable,nonatomic,copy) NSDictionary<NSString *,id> *titleTextAttributes;
@property(nullable,nonatomic,copy) NSDictionary<NSString *,id> *titleTextAttributes;
(7)设置左侧POP按钮的图片
@property(nullable,nonatomic,strong) UIImage *backIndicatorImage;
@property(nullable,nonatomic,strong) UIImage *backIndicatorTransitionMaskImage;
(8) UINavigationBarDelegate
- (
BOOL
)navigationBar:(UINavigationBar *)navigationBar shouldPushItem:(UINavigationItem *)item;
//item已经push后调用
- (
void
)navigationBar:(UINavigationBar *)navigationBar didPushItem:(UINavigationItem *)item;
//item将要pop时调用,返回NO,不能pop
- (
BOOL
)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item;
//item已经pop后调用
- (
void
)navigationBar:(UINavigationBar *)navigationBar didPopItem:(UINavigationItem *)item;
|
3 navigationItem (导航栏中管理的一个项目的抽象)
item 这个项目 可以管理导航栏的 label标题 和 左右两个按钮
(1)管理中间的label标题
UINavigationItem * item = [[UINavigationItem alloc]initWithTitle:@
"title"
];
UINavigationBar * bar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 64)];
[bar pushNavigationItem:item animated:YES];// 把Item项目添加到导航栏上 这样才会有效
(2)创建一个View 类型的Item 当然 这个包括view 的子类 如 UIButton UIImageView 等
UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
view.backgroundColor = [UIColor brownColor];
item.titleView = view; // 主要调用的是这个方法
(3)给这个Item添加一个说明文字,这段文字会显示在item的上方
item.prompt= @
"我是navigationItem的说明文字"
;
(4)BarButtonItem 是 navigationItem 的子类
UIBarButtonItem * button = [[UIBarButtonItem alloc]initWithTitle:@"按钮" style:UIBarButtonItemStyleDone target:self action:@selector(click)];
item.leftBarButtonItem = button;
- (instancetype)initWithImage:(nullable UIImage *)image style:(UIBarButtonItemStyle)style target:(nullable id)target action:(nullable SEL)action;
- (instancetype)initWithImage:(nullable UIImage *)image landscapeImagePhone:(nullable UIImage *)landscapeImagePhone style:(UIBarButtonItemStyle)style target:(nullable id)target action:(nullable SEL)action;
- (instancetype)initWithCustomView:(UIView *)customView;
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,
//显示前进按钮
UIBarButtonSystemItemUndo,
//显示消除按钮
UIBarButtonSystemItemRedo ,
//显示重做按钮
UIBarButtonSystemItemPageCurl ,
//在tool上有效
};
|