CJBorderView
An easy way to init a view with dotted line border
Author:CoderChenJun
Email:Coder.ChenJun@qq.com
目录
DescriptionUsageStatement
Description
CJBorderView头文件
@interface CJBorderView : UIView
/** 边框线 类型 : 实线\虚线 */
@property (assign, nonatomic) BorderType borderType;
/** 边框线 圆角度数 */
@property (assign, nonatomic) CGFloat cornerRadius;
/** 边框线 宽度 */
@property (assign, nonatomic) CGFloat borderWidth;
/** 边框线 虚线部分长度 */
@property (assign, nonatomic) NSUInteger dashPattern;
/** 边框线 实线部分长度 */
@property (assign, nonatomic) NSUInteger spacePattern;
/** 边框线 颜色 默认黑色 */
@property (strong, nonatomic) UIColor *borderColor;
@end
BorderType枚举,包含如下几种类型
typedef NS_ENUM(NSInteger, BorderType) {
/** 虚线 */
BorderTypeDashed,
/** 实线 */
BorderTypeSolid
};
Usage
BorderTypeDashed-虚线
CJBorderView *view1 = [[CJBorderView alloc] initWithFrame:CGRectMake(
50,
50,
100,
100)]
view1
.backgroundColor = [UIColor redColor]
view1
.borderType = BorderTypeDashed
view1
.cornerRadius =
10
view1
.borderWidth =
2
view1
.dashPattern =
10
view1
.spacePattern =
10
view1
.borderColor = [UIColor blackColor]
[self
.view addSubview:view1]
BorderTypeSolid-实线(一旦设置类型为实线,所有虚线属性设置均无效)
CJBorderView *view2 = [[CJBorderView alloc] initWithFrame:CGRectMake(
200,
50,
50,
100)]
view2
.backgroundColor = [UIColor brownColor]
view2
.borderType = BorderTypeSolid
view2
.cornerRadius =
10
view2
.borderWidth =
2
view2
.dashPattern =
5
view2
.spacePattern =
10
view2
.borderColor = [UIColor blackColor]
[self
.view addSubview:view2]
Statement
此博客为原创博客,供大家学习参考并使用。
若转载请注明“本文转载自CoderChenJun的博客(http://blog.csdn.net/Coder_ChenJun/article/details/74988866)”,谢谢。
CJHUD 的github地址:https://github.com/CoderChenJun/CJBorderView