// // POBaseStyleTableViewCell.h // powerone // // Created by kinghai on 2018/8/3. // Copyright © 2018年 onecloud.ltd. All rights reserved. // /** 样式设置文件 */ #import #define IconCornerRadius GetUserHead_shape ? 3.0 : AvatarImageViewWidthOrHeight / 2.0 //头像圆角半径 #define CellStyleViewLeftRightMargin 8 //cell的阴影圆角距离左右边距 #define CellStyleViewVerticalMargin 10 //两个阴影圆角cell的距离 或 cell距离顶部 #define StyleButtonHeight 40 //按钮高度 #define StyleButtonCornerRadius 3 //按钮圆角半径 #define StyleButtonWithCellLeftRightMargin 8 //按钮在tableViewCell下面时的左右边距 #define StyleButtonWithCellTopMargin 20 //按钮在tableViewCell下面时的距离上面cell的边距 #define StyleButtonWithoutCellLeftRightMargin 58 //按钮不在tableViewCell下面时的左右边距 #define StyleButtonBorderColorGrey UIColorFromHex(0xd2d2d2) //白色按钮的边框颜色 #define StyleButtonColorWhite UIColorFromHex(0xFBFBFB) //白色按钮 #define StyleButtonColorGreen kAppThemeColor //绿色按钮 #define StyleButtonColorRed kAppRedColor //红色按钮 #define StyleButtonTitleColorBlack kBlackColor_3 //按钮黑色标题 #define StyleButtonTitleColorWhite YHColor(255, 255, 255) //按钮白色标题(不能使用[UIColor whiteColor],会导致CGColorGetNumberOfComponents返回2) #define StyleButtonTitleColorRed [UIColor redColor] //按钮红色标题 #define AddressListSectionHeaderHeight 20 //通讯录的组的头视图高度 #define SeparatorLineViewHeight 0.8 //分隔线的高度 /** 哪一边无阴影 */ typedef NS_ENUM(NSInteger, PONoShadowSide) { PONoShadowSideNone = 1 << 0, //没有边是无阴影的,即四边都有阴影 PONoShadowSideLeft = 1 << 1, //左边无阴影 PONoShadowSideRight = 1 << 2, //右边无阴影 PONoShadowSideTop = 1 << 3, //上边无阴影 PONoShadowSideBottom = 1 << 4, //下边无阴影 PONoShadowSideAll = 1 << 5, //四边都无阴影 }; /** 设置样式所需的数据 */ @interface POCellStyleDataModel : NSObject /** 圆角半径(0代表无圆角) */ @property (nonatomic, assign) CGFloat cornerRadius; /** 是否有阴影 */ @property (nonatomic, assign) BOOL showShadow; /** 阴影颜色 */ @property (nonatomic, strong) UIColor *shadowColor; /** 阴影不透明度 */ @property (nonatomic, assign) CGFloat shadowOpacity; /** 阴影偏移 */ @property (nonatomic, assign) CGSize shadowOffset; /** 阴影半径 */ @property (nonatomic, assign) CGFloat shadowRadius; /** 要设置圆角的位置(当corners不是全部四个圆角时,必须设置styleViewSize,否则显示错误) */ @property (nonatomic, assign) UIRectCorner corners; /** 圆角背景视图的高宽(当corners不是全部四个圆角时,必须设置这个属性,否则显示错误) */ @property (nonatomic, assign) CGSize styleViewSize; /** 没有阴影的边 */ @property (nonatomic, assign) PONoShadowSide noShadowSide; /** 背景卡片距离cell的边距 */ @property (nonatomic, assign) UIEdgeInsets edgeInsets; /** cell背景颜色 */ @property (nonatomic, strong) UIColor *cellBackgroundColor; @end /** cell的特殊样式背景视图,用init初始化,然后调用setupViewWithStyleModel才能设置特定样式 */ @interface POCellStyleBackgroundView : UIView /** 风格model*/ @property (nonatomic, strong) POCellStyleDataModel *styleModel; @end /** 具有卡片样式的cell 使用方法: ①直接继承POBaseStyleTableViewCell,使用默认的styleBackgroundView(在用initWithStyle:reuseIdentifier:初始化cell时创建),设置了四个圆角+距离cell边距为(5,8,5,8)+阴影; ②如果需要修改默认的styleBackgroundView,可以在子类cell的initWithStyle:reuseIdentifier:方法中设置styleModel进行修改,适用于子类cell的所有实例都是这个样式;如果子类cell的不同实例需要不同的styleBackgroundView(比如section的第一个cell只有上部分圆角、最后一个cell只有下部分圆角、中间cell无圆角),则在cellForRowAtIndexPath中为每个cell设置不同的styleModel。 注意: 子类cell的backgroundColor需要是clearColor;子类cell的子视图不能遮盖styleBackgroundView;reloadRowsAtIndexPaths如果数组有两个元素会导致阴影闪烁,只能一个一个reload。 */ @interface POBaseStyleTableViewCell : UITableViewCell /** 具有样式的cell背景视图,比如有圆角阴影(由于_styleBackgroundView在最底层,所以它的子视图无法响应手势,需要响应手势的子视图添加到self或self.contentView) */ @property (nonatomic, strong, readonly) POCellStyleBackgroundView *styleBackgroundView; /** 设置cell背景样式所需的数据(如果styleModel=nil或者styleModel的某个属性值为空,则使用默认值) */ @property (nonatomic, strong) POCellStyleDataModel *styleModel; @end