700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > CJBorderView 一种iOS开发中常用的虚线边框View------* An easy way to init a view with dotted line border

CJBorderView 一种iOS开发中常用的虚线边框View------* An easy way to init a view with dotted line border

时间:2023-10-26 16:47:12

相关推荐

CJBorderView 一种iOS开发中常用的虚线边框View------* An easy way to init a view with dotted line border

CJBorderView

An easy way to init a view with dotted line border

Author:CoderChenJun

Email:Coder.ChenJun@

目录

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的博客(/Coder_ChenJun/article/details/74988866)”,谢谢。

CJHUD的github地址:/CoderChenJun/CJBorderView

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。