UIView简单用法
来源:互联网 发布:关于太空的软件 编辑:程序博客网 时间:2024/05/10 01:26
//// MyView.swift// L01Test//// Created by robertkun on 15/9/7.// Copyright (c) 2015 MAC. All rights reserved.//import UIKitclass MyView: UIView { private var nValue:CGFloat = 0; private var path = CGPathCreateMutable() override init(frame: CGRect) { super.init(frame: frame) } required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) fatalError("init(coder:) has not been implemented") } func setProgessValue(value:CGFloat) { nValue = value setNeedsDisplay() } func getProgessValue()->CGFloat { return nValue; } override func drawRect(rect: CGRect) { // Drawing code var context = UIGraphicsGetCurrentContext() CGContextSetRGBFillColor(context, 1, 1, 1, 1) CGContextSetLineWidth(context, 5) CGContextAddPath(context, path) CGContextFillPath(context) var r = rect.width/2 UIColor.blackColor().set() CGContextAddArc(context, r, r, r, 0, 3.14*2*r, 0) CGContextFillPath(context) UIColor.redColor().set() CGContextAddArc(context, r, r, r, 0, 3.14*2*nValue, 0) CGContextAddLineToPoint(context, r, r) CGContextFillPath(context) } override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { let p = (touches as NSSet).anyObject()?.locationInView(self) CGPathMoveToPoint(path, nil, p!.x, p!.y) } override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) { let p = (touches as NSSet).anyObject()?.locationInView(self) CGPathAddLineToPoint(path, nil, p!.x, p!.y) setNeedsDisplay() }}
0 0
- UIView简单用法
- UIView 基本用法
- UIview基本用法
- UIView的一些用法
- UIView基本用法
- UIView animation常用用法
- UIView的常见用法
- UIView 基本属性用法
- UIView简单阴影
- UIview简单动画
- UIView简单使用
- UIView简单动画
- UIview 简单动画
- ios--UIView简单动画
- Swift UIview简单动画
- CYC- 简单UIView动画
- UIView的简单动画
- swift UIView简单动画
- iOS中防止两个按钮同时点击的方法
- IoC控制反转--管理Bean
- WebSocket快速入门
- 模拟Tomcat服务器
- 《海瑞官场笔记》有感
- UIView简单用法
- hbase 学习梳理
- 一些英文缩写的名称
- Python的AOP利器:装饰器
- 基于unix的xmlrpc 服务器和客户端源码
- ubuntu安装中文输入法fcitx
- 通用解析搜索关键词类
- 《女推拿师》后感
- 机器学习中的ground truth