- 浏览: 647979 次
- 性别:
- 来自: 北京
-
文章分类
最新评论
-
lizaochengwen:
网络请求碰到的中文乱码使用encodeURL吧- (NSStr ...
iPhone开发/iPad开发 中文乱码问题 -
hhb19900618:
还是没弄懂怎么解决了中文乱码? 正确代码能重写贴出吗
iPhone开发/iPad开发 中文乱码问题 -
zhengjj_2009:
我的理解是讲ipa文件解压缩之后再重新打包,已经破坏了签名,所 ...
xcodebuild和xcrun实现自动打包iOS应用程序 -
zhengjj_2009:
我参考你的“ 从ipa格式的母包生成其它渠道包的shell脚本 ...
xcodebuild和xcrun实现自动打包iOS应用程序 -
同一片天空:
问题果然解决了
iOS 搭建 XMPP实现环境
PaintView.h
CGPoint lastPoint;
UIImageView *lineImageView;
PaintView.m
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
lineImageView = [[UIImageView alloc] initWithFrame:frame];
lineImageView.backgroundColor = [UIColor grayColor];
[self addSubview:lineImageView];
}
return self;
}
- (void)drawRect:(CGRect)rect
{
CGContextRef c = UIGraphicsGetCurrentContext(); // 获取当前的设备上下文,必须在drawRect中获取,否则会出错
CGContextSetLineCap(context, kCGLineCapRound); // 设置划线样式
CGContextSetLineWidth(context, 6);
CGContextSetRGBStrokeColor(context, 0, 0, 0, 1); // 设置画出的线的颜色信息
CGContextBeginPath(context);
CGContextMoveToPoint(context, 10, 10);
CGContextAddLineToPoint(context, 100, 100);
CGContextStrokePath(context); // 绘出图形
[super drawRect:rect];
}
// 移动鼠标划线
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *aTouch = [touches anyObject];
lastPoint = [aTouch locationInView:self];
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
CGContextSetAllowsAntialiasing(context, YES);
CGContextMoveToPoint(context, 0, 15);
CGContextAddEllipseInRect(context, CGRectMake(0, 0, 70, 70));
CGContextDrawPath(context, 1);
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *aTouch = [touches anyObject];
CGPoint currentPoint = [aTouch locationInView:self];
UIGraphicsBeginImageContext(self.frame.size); // 创建一个bitmap设备上下文 如果不创建,UIGraphicsGetCurrentContext()不能获取当前设备上下文
[lineImageView.image drawInRect:CGRectMake(0, 0, 768, 1024)]; // 设置图形的显示区域
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 7);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 1.0, 1.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
[lineImageView setImage:UIGraphicsGetImageFromCurrentImageContext()];
UIGraphicsEndImageContext(); // 关闭创建的设备上下文
lastPoint = currentPoint;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UIGraphicsBeginImageContext(self.frame.size);
[lineImageView.image drawInRect:CGRectMake(0, 0, 768, 1024)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 7);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 1.0, 1.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
[lineImageView setImage:UIGraphicsGetImageFromCurrentImageContext()];
UIGraphicsEndImageContext();
}
CGPoint lastPoint;
UIImageView *lineImageView;
PaintView.m
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
lineImageView = [[UIImageView alloc] initWithFrame:frame];
lineImageView.backgroundColor = [UIColor grayColor];
[self addSubview:lineImageView];
}
return self;
}
- (void)drawRect:(CGRect)rect
{
CGContextRef c = UIGraphicsGetCurrentContext(); // 获取当前的设备上下文,必须在drawRect中获取,否则会出错
CGContextSetLineCap(context, kCGLineCapRound); // 设置划线样式
CGContextSetLineWidth(context, 6);
CGContextSetRGBStrokeColor(context, 0, 0, 0, 1); // 设置画出的线的颜色信息
CGContextBeginPath(context);
CGContextMoveToPoint(context, 10, 10);
CGContextAddLineToPoint(context, 100, 100);
CGContextStrokePath(context); // 绘出图形
[super drawRect:rect];
}
// 移动鼠标划线
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *aTouch = [touches anyObject];
lastPoint = [aTouch locationInView:self];
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
CGContextSetAllowsAntialiasing(context, YES);
CGContextMoveToPoint(context, 0, 15);
CGContextAddEllipseInRect(context, CGRectMake(0, 0, 70, 70));
CGContextDrawPath(context, 1);
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *aTouch = [touches anyObject];
CGPoint currentPoint = [aTouch locationInView:self];
UIGraphicsBeginImageContext(self.frame.size); // 创建一个bitmap设备上下文 如果不创建,UIGraphicsGetCurrentContext()不能获取当前设备上下文
[lineImageView.image drawInRect:CGRectMake(0, 0, 768, 1024)]; // 设置图形的显示区域
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 7);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 1.0, 1.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
[lineImageView setImage:UIGraphicsGetImageFromCurrentImageContext()];
UIGraphicsEndImageContext(); // 关闭创建的设备上下文
lastPoint = currentPoint;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UIGraphicsBeginImageContext(self.frame.size);
[lineImageView.image drawInRect:CGRectMake(0, 0, 768, 1024)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 7);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 1.0, 1.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
[lineImageView setImage:UIGraphicsGetImageFromCurrentImageContext()];
UIGraphicsEndImageContext();
}
发表评论
-
SOCK_STREAM和SOCK_DGRAM
2015-07-23 20:08 1586sock_stream 是有保障的(即能保证数据正确传送到 ... -
SOCKET bind INADDR_LOOPBACK和INADDR_ANY的区别
2015-07-23 19:49 2022今天写程序时候,服务器端启动了,然后客户端总是连接不上,con ... -
htons()
2015-07-23 19:26 547在C/C++写网络程序的时候,往往会遇到字节的网络顺序和主机顺 ... -
使用symbolicatecrash分析crash文件
2015-03-10 11:32 1142原文 http://www.cnblogs.com/ning ... -
程序设计中的计算复用(Computational Reuse)
2015-02-10 10:18 622从斐波那契数列说起 ... -
didReceiveMemoryWarning
2015-02-09 16:11 507IPhone下每个app可用的内存是被限制的,如果一个app使 ... -
iOS开发中怎么响应内存警告
2015-02-09 16:08 623好的应用应该在系统内存警告情况下释放一些可以重新创建的资源。在 ... -
ASIHTTPRequest多次重复请求的问题
2014-12-17 14:34 610在一个车票订购的项目中,点击一次订购,却生成了2次订单,通过抓 ... -
从 CloudKit 看 BaaS 服务的趋势
2014-09-26 11:51 703从 6 月份 WWDC 苹果发布 ... -
ios编程--AVCapture编程理解
2014-09-26 11:03 8900、媒体采集的几个东西。这里所需要明白的是,在这个流程中,这里 ... -
NSURLProtocol
2014-09-25 10:42 7751、http://nshipster.com/nsurlpro ... -
关于iOS8的extension插件
2014-09-25 10:41 1236关于iOS8的extension插件,有兴趣的同学可以参考一下 ... -
【转】ios app在itunesConnect里面的几种状态
2014-08-05 10:34 1109Waiting for Upload (Yellow) Ap ... -
[转]iOS Dev (45) iOS图标与切片处理工具Prepo
2014-02-07 17:02 1002iOS Dev (45) iOS图标与切片处理工具Prepo ... -
phoneGap开发IOS,JS调用IOS方法/phoneGap插件开发
2014-01-13 17:49 1221前沿 废话不说phoneGap是什么不多介绍,官方网站: h ... -
如何在IOS平台下搭建PhoneGap开发环境(PhoneGap2.5)
2014-01-13 15:23 713由于在下最近在做基于HTML5的跨平台移植,搭建环境的时候着实 ... -
xcode 4 制作静态库详解
2013-12-20 18:27 502最近在做Apple的IOS开发,有开发静态库的需求,本身IOS ... -
【翻译】ios教程-创建静态库
2013-12-20 18:19 3030作者:shede333 主页:htt ... -
封装自己的控件库:iPhone静态库的应用
2013-12-20 17:03 525由于iPhone 控件的极度匮乏和自定义组件在重用上的限制,在 ... -
iphone:使用NSFileManager取得目录下所有文件(遍历所有文件)
2013-11-18 17:56 840From:http://note.sdo.com/u/xiao ...
相关推荐
WPF用鼠标在Canvas画线,通过左击获得线的起点,通过移动并释放左键获得终点实现画线功能。
canvas动态划线(canvas跟随鼠标变幻线条,知乎登录页面动态线条背景动画代码) 每次被下载,所需积分就被平台自动叠加,感觉有点傻,无奈重新编辑上传,感觉可选的这个1-5积分就有点少,算了无所谓了你们能下载就好
用easyx实现拖动画线,一般画线是点两点然后直接画出线。但我的可以实现类似画图中直线的作用。鼠标左键按住拖动画线。
C++实现鼠标的轨迹
VC画基准线,鼠标左键按下时开始画,然后基准线随着鼠标的移动而移动,在鼠标左键弹起时停止移动!
本例代码使用了Python的PyQt5、matplotlib和Dataframe画图,并在图中添加了一条随鼠标移动的虚线,之后经过计算在画图的线上标注出了鼠标在当时x轴停留时的数据,本例只是一个简单的例子,自己可以根据功能修改
根据鼠标移动在屏幕上画线,使用全局DC可以修改坐标在全局画线
通过鼠标点击完成画线,是GIS初学者必须掌握的技能。
在图形中,随着鼠标的移动显示十字交叉线,VC++
visual c++制作 图片跟着鼠标移动,显示鼠标移动轨迹
要在界面上按下鼠标,拖动之后松开鼠标,然后就在界面上绘制出了线、矩形和圆形 代码用了抽象的概念,将三种图形抽象成了一个myShape,在代码中的体现就是定义了一个基类myShape类,其他所有的图像类都继承自这个...
C#chart控件游标CursorX跟随鼠标移动的例子。
主要介绍了C#实现鼠标移动到曲线图上显示值的方法,是C#的WinForm窗体程序设计中非常实用的技巧,需要的朋友可以参考下
记录鼠标点击次序并实现平滑画线,以线做轨迹进行移动,可以做为人员或车辆行走轨迹处理。
鼠标经过背景显示线条,鼠标经过背景显示线条,跟着鼠标移动,鼠标移动到哪就会到哪。跟着鼠标移动,鼠标移动到哪就会到哪。
vc++制作,实现鼠标左键按下时显示“猪头”,然后移动鼠标画线,在鼠标弹起处显示“猪尾巴”。
在VC++里拖动鼠标,绘制直线,很简单,但很经典
鼠标移动时,会吸附背景中漂浮的线条,组成一个伞形。
Canvas点击跟随鼠标移动特效是一款基于html5 canvas实现的移动的光线动画。