画图工具PaintCode的使用
2016-06-08 15:05
411 查看
PaintCode 是一个专门为设计师准备的简单的矢量图形绘图应用程序,你可以通过在工具画图自动获取OC代码。
最新的PaintCode2已经可以实现控件的使用(APP
Store中是收费的 还比较贵),只要你能将实现的界面画出来,就可以生成相应的代码,界面的UI布局编码从来都是最浪费时间的东西,PaintCode2可以直接生成代码,当然存在一些不成熟的地方,比如控件之间的相对位置处理,代码仅仅是相对于整个页面的位置(数字表示),这是我觉得比较不成熟的一点,也是很难改进的一点。
虽然有一定缺陷,但是PaintCode
对于画图方面还是有很大用途的,可以通过这个工具描述图形路径,并生成相应的OC或Swift代码。使用很方便,只要在工具中画出想要的图形轮廓就可以获取到相应代码,可以直接拿到项目中使用的。 这只是其中简单的功能,其它功能想要使用还需要自己去开发,因为很多功能是收费的。
下面是画图功能的展示:
代码事例:
@interface
HuaTuViewController
()
@property
(strong,nonatomic)
UIView
*launchView;
@property
(strong,nonatomic)
CAGradientLayer*gradientLayer;
@property
(strong,
nonatomic)
NSTimer
*timer;
@end
@implementation
HuaTuViewController
- (void)viewDidLoad {
[super
viewDidLoad];
[self
addLayerToLaunchView];
// Do any additional setup after loading the view.
}
#pragma mark --
手绘图形显示(CAShapeLayer)(使用
paintCode
工具获取画图代码)
-(void)addLayerToLaunchView
{
self.launchView
= [[UIView
alloc]initWithFrame:CGRectMake(0,
0,
100,
100)];
self.launchView.center
=
self.view.center;
self.launchView.alpha
=
1;
[self.view
addSubview:self.launchView];
//self.launchView是我添加的一个显示Logo的UIVIew
//CAShapeLayer主要是线性,path
里面对颜色的设置无法直接跟随生成,需要单独设置如下:
/*
1.
线颜色
@property CGColorRef strokeColor
2.
填充色
@property CGColorRef fillColor
3.
填充规则
@property(copy) NSString *fillRule
*/
CAShapeLayer *layer = [[CAShapeLayer
alloc]init];
layer.path
= [self
setBezierPath4].CGPath;
layer.bounds
=
CGPathGetBoundingBox(layer.path);
[self.launchView.layer
addSublayer:layer];
CAShapeLayer *layer2 = [[CAShapeLayer
alloc]init];
layer2.path
= [self
setBezierPath2].CGPath;
layer2.bounds
= CGPathGetBoundingBox(layer.path);
layer2.fillColor
= [UIColor
greenColor].CGColor;
[self.launchView.layer
addSublayer:layer2];
}
-(UIBezierPath*)setBezierPath4
{
//// PaintCode Trial Version
////
www.paintcodeapp.com
//// General Declarations
CGColorSpaceRef colorSpace =
CGColorSpaceCreateDeviceRGB();
CGContextRef context =
UIGraphicsGetCurrentContext();
//// Color Declarations
UIColor* color = [UIColor
colorWithRed:
0.756
green:
0.109
blue:
0.109
alpha:
1];
//// Gradient Declarations
CGFloat gradientLocations[] = {0,
1};
CGGradientRef gradient =
CGGradientCreateWithColors(colorSpace, (__bridge
CFArrayRef)@[(id)UIColor.greenColor.CGColor,
(id)UIColor.whiteColor.CGColor],
gradientLocations);
//// Bezier Drawing
UIBezierPath* bezierPath = [UIBezierPath
bezierPath];
[bezierPath
moveToPoint:
CGPointMake(214.5,
150.5)];
[bezierPath
addCurveToPoint:
CGPointMake(193.5,
189.5)
controlPoint1:
CGPointMake(242.5,
150.5)
controlPoint2:
CGPointMake(175.5,
168.5)];
[bezierPath
addCurveToPoint:
CGPointMake(235.5,
196.5)
controlPoint1:
CGPointMake(211.5,
210.5)
controlPoint2:
CGPointMake(267.5,
185.5)];
[bezierPath
addCurveToPoint:
CGPointMake(172.5,
207.5)
controlPoint1:
CGPointMake(203.5,
207.5)
controlPoint2:
CGPointMake(206.5,
218.5)];
[bezierPath
addCurveToPoint:
CGPointMake(103.5,
222.5)
controlPoint1:
CGPointMake(144.18,
198.34)
controlPoint2:
CGPointMake(97.84,
229.67)];
[bezierPath
addCurveToPoint:
CGPointMake(122.5,
189.5)
controlPoint1:
CGPointMake(104.64,
221.06)
controlPoint2:
CGPointMake(119.49,
192.84)];
[bezierPath
addCurveToPoint:
CGPointMake(214.5,
150.5)
controlPoint1:
CGPointMake(140.5,
169.5)
controlPoint2:
CGPointMake(186.5,
150.5)];
[bezierPath
closePath];
CGContextSaveGState(context);
[bezierPath
addClip];
CGContextDrawLinearGradient(context, gradient,
CGPointMake(174.11,
150.5),
CGPointMake(174.11,
223.58),
0);
CGContextRestoreGState(context);
[color
setStroke];
bezierPath.lineWidth
=
1;
[bezierPath
stroke];
//// Cleanup
CGGradientRelease(gradient);
CGColorSpaceRelease(colorSpace);
return bezierPath;
}
-(UIBezierPath*)setBezierPath2
{
//// Color Declarations
UIColor* color2 = [UIColor
colorWithRed:
1
green:
0.769
blue:
0 alpha:
1];
//// Star 2 Drawing
UIBezierPath* star2Path = [UIBezierPath
bezierPath];
[star2Path
moveToPoint:
CGPointMake(88,
58)];
[star2Path
addLineToPoint:
CGPointMake(89.76,
61.09)];
[star2Path
addLineToPoint:
CGPointMake(92.76,
62.15)];
[star2Path
addLineToPoint:
CGPointMake(90.85,
65.11)];
[star2Path
addLineToPoint:
CGPointMake(90.94,
68.85)];
[star2Path
addLineToPoint:
CGPointMake(88,
67.6)];
[star2Path
addLineToPoint:
CGPointMake(85.06,
68.85)];
[star2Path
addLineToPoint:
CGPointMake(85.15,
65.11)];
[star2Path
addLineToPoint:
CGPointMake(83.24,
62.15)];
[star2Path
addLineToPoint:
CGPointMake(86.24,
61.09)];
[star2Path
closePath];
[color2
setFill];
[star2Path
fill];
return star2Path;
}
@end
最新的PaintCode2已经可以实现控件的使用(APP
Store中是收费的 还比较贵),只要你能将实现的界面画出来,就可以生成相应的代码,界面的UI布局编码从来都是最浪费时间的东西,PaintCode2可以直接生成代码,当然存在一些不成熟的地方,比如控件之间的相对位置处理,代码仅仅是相对于整个页面的位置(数字表示),这是我觉得比较不成熟的一点,也是很难改进的一点。
虽然有一定缺陷,但是PaintCode
对于画图方面还是有很大用途的,可以通过这个工具描述图形路径,并生成相应的OC或Swift代码。使用很方便,只要在工具中画出想要的图形轮廓就可以获取到相应代码,可以直接拿到项目中使用的。 这只是其中简单的功能,其它功能想要使用还需要自己去开发,因为很多功能是收费的。
下面是画图功能的展示:
代码事例:
@interface
HuaTuViewController
()
@property
(strong,nonatomic)
UIView
*launchView;
@property
(strong,nonatomic)
CAGradientLayer*gradientLayer;
@property
(strong,
nonatomic)
NSTimer
*timer;
@end
@implementation
HuaTuViewController
- (void)viewDidLoad {
[super
viewDidLoad];
[self
addLayerToLaunchView];
// Do any additional setup after loading the view.
}
#pragma mark --
手绘图形显示(CAShapeLayer)(使用
paintCode
工具获取画图代码)
-(void)addLayerToLaunchView
{
self.launchView
= [[UIView
alloc]initWithFrame:CGRectMake(0,
0,
100,
100)];
self.launchView.center
=
self.view.center;
self.launchView.alpha
=
1;
[self.view
addSubview:self.launchView];
//self.launchView是我添加的一个显示Logo的UIVIew
//CAShapeLayer主要是线性,path
里面对颜色的设置无法直接跟随生成,需要单独设置如下:
/*
1.
线颜色
@property CGColorRef strokeColor
2.
填充色
@property CGColorRef fillColor
3.
填充规则
@property(copy) NSString *fillRule
*/
CAShapeLayer *layer = [[CAShapeLayer
alloc]init];
layer.path
= [self
setBezierPath4].CGPath;
layer.bounds
=
CGPathGetBoundingBox(layer.path);
[self.launchView.layer
addSublayer:layer];
CAShapeLayer *layer2 = [[CAShapeLayer
alloc]init];
layer2.path
= [self
setBezierPath2].CGPath;
layer2.bounds
= CGPathGetBoundingBox(layer.path);
layer2.fillColor
= [UIColor
greenColor].CGColor;
[self.launchView.layer
addSublayer:layer2];
}
-(UIBezierPath*)setBezierPath4
{
//// PaintCode Trial Version
////
www.paintcodeapp.com
//// General Declarations
CGColorSpaceRef colorSpace =
CGColorSpaceCreateDeviceRGB();
CGContextRef context =
UIGraphicsGetCurrentContext();
//// Color Declarations
UIColor* color = [UIColor
colorWithRed:
0.756
green:
0.109
blue:
0.109
alpha:
1];
//// Gradient Declarations
CGFloat gradientLocations[] = {0,
1};
CGGradientRef gradient =
CGGradientCreateWithColors(colorSpace, (__bridge
CFArrayRef)@[(id)UIColor.greenColor.CGColor,
(id)UIColor.whiteColor.CGColor],
gradientLocations);
//// Bezier Drawing
UIBezierPath* bezierPath = [UIBezierPath
bezierPath];
[bezierPath
moveToPoint:
CGPointMake(214.5,
150.5)];
[bezierPath
addCurveToPoint:
CGPointMake(193.5,
189.5)
controlPoint1:
CGPointMake(242.5,
150.5)
controlPoint2:
CGPointMake(175.5,
168.5)];
[bezierPath
addCurveToPoint:
CGPointMake(235.5,
196.5)
controlPoint1:
CGPointMake(211.5,
210.5)
controlPoint2:
CGPointMake(267.5,
185.5)];
[bezierPath
addCurveToPoint:
CGPointMake(172.5,
207.5)
controlPoint1:
CGPointMake(203.5,
207.5)
controlPoint2:
CGPointMake(206.5,
218.5)];
[bezierPath
addCurveToPoint:
CGPointMake(103.5,
222.5)
controlPoint1:
CGPointMake(144.18,
198.34)
controlPoint2:
CGPointMake(97.84,
229.67)];
[bezierPath
addCurveToPoint:
CGPointMake(122.5,
189.5)
controlPoint1:
CGPointMake(104.64,
221.06)
controlPoint2:
CGPointMake(119.49,
192.84)];
[bezierPath
addCurveToPoint:
CGPointMake(214.5,
150.5)
controlPoint1:
CGPointMake(140.5,
169.5)
controlPoint2:
CGPointMake(186.5,
150.5)];
[bezierPath
closePath];
CGContextSaveGState(context);
[bezierPath
addClip];
CGContextDrawLinearGradient(context, gradient,
CGPointMake(174.11,
150.5),
CGPointMake(174.11,
223.58),
0);
CGContextRestoreGState(context);
[color
setStroke];
bezierPath.lineWidth
=
1;
[bezierPath
stroke];
//// Cleanup
CGGradientRelease(gradient);
CGColorSpaceRelease(colorSpace);
return bezierPath;
}
-(UIBezierPath*)setBezierPath2
{
//// Color Declarations
UIColor* color2 = [UIColor
colorWithRed:
1
green:
0.769
blue:
0 alpha:
1];
//// Star 2 Drawing
UIBezierPath* star2Path = [UIBezierPath
bezierPath];
[star2Path
moveToPoint:
CGPointMake(88,
58)];
[star2Path
addLineToPoint:
CGPointMake(89.76,
61.09)];
[star2Path
addLineToPoint:
CGPointMake(92.76,
62.15)];
[star2Path
addLineToPoint:
CGPointMake(90.85,
65.11)];
[star2Path
addLineToPoint:
CGPointMake(90.94,
68.85)];
[star2Path
addLineToPoint:
CGPointMake(88,
67.6)];
[star2Path
addLineToPoint:
CGPointMake(85.06,
68.85)];
[star2Path
addLineToPoint:
CGPointMake(85.15,
65.11)];
[star2Path
addLineToPoint:
CGPointMake(83.24,
62.15)];
[star2Path
addLineToPoint:
CGPointMake(86.24,
61.09)];
[star2Path
closePath];
[color2
setFill];
[star2Path
fill];
return star2Path;
}
@end
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 讲解iOS开发中基本的定位功能实现
- iOS中定位当前位置坐标及转换为火星坐标的方法
- js判断客户端是iOS还是Android等移动终端的方法
- iOS应用开发中AFNetworking库的常用HTTP操作方法小结
- iOS应用中UISearchDisplayController搜索效果的用法
- iOS App开发中的UISegmentedControl分段组件用法总结
- IOS开发环境windows化攻略
- iOS应用中UITableView左滑自定义选项及批量删除的实现
- iOS中UIAlertView警告框组件的使用教程
- 浅析iOS应用开发中线程间的通信与线程安全问题
- 检测iOS设备是否越狱的方法
- .net平台推送ios消息的实现方法
- 探讨Android与iOS,我们将何去何从?