IOS学习随笔三

 
IOS storyboard做界面跳转设计页面:
self.dismissViewControllerAnimated(true, completion: nil ) ios8已经替换掉了老得方法定义  使用两个参数的dismissViewControllerAnimated
NIB做界面设计:
self.presentViewController(MyViewController(nibName: "MyViewController", bundle: nil), animated: true, completion: nil)
MyViewConroller是自己搭建的UIViewController子类,同时生成了nib文件
 iOS绘图API
1绘图的第一步是声明一个
 var context = UIGraphicsGetCurrentContext() ;//用来保存当前的绘图内容
2可以通过 CGContextAddLineToPoint 画直线  ,线需要先确定一个点----CGContextMoveToPoint
通过 CGContextAddRect 画矩形
通过 CGContextAddArc画扇形-----》和圆
通过  CGContextAddEllipseInRect来画一个矩形的内接圆———椭圆和圆
通过 CGContextDrawImage 来把画图片呈现到视图上,
这里需要先通过CGContextScaleCTM//首先放入的图是倒过来的,图片和试图的编码方式导致y是-1
3CGcontextSet 等方法来设置这些图像的属性比如颜色和线框等
4显示图形,通过CGContextStrokePath(context)来显示线 ,通过CGContextFillPath(context)来显示填充
绘图中
//为了不在绘制图的时候影响其他绘图,先保存状态,然后再恢复
        CGContextSaveGState(context)
        CGContextRestoreGState(context)
2-13画板实例
首先重载两个方法
touchesBegan(touches: NSSet, withEvent event: UIEvent)
{
//确定触摸的起始点
var p = touches.anyObject()?.locationInView(self)
CGPathMoveToPoint(path, nil, p!.x , p!.y)
}
touchesMoved(touches: NSSet, withEvent event: UIEvent)
{ var p = touches.anyObject()?.locationInView(self)
 CGPathAddLineToPoint(path, nil, p!.x, p!.y)  
   setNeedsDisplay();//显示图形
 
}
 
 
 
 

转载于:https://www.cnblogs.com/KyleRuan/p/4296081.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值