import UIKit

class LolitaCircleButton: UIButton {

    private var color: UIColor
private var imageURL: String init(color: UIColor , imageURL: String) {
self.color = color
self.imageURL = imageURL
super.init(frame: CGRectZero) commonInit()
layer.shadowOpacity = 0.3
layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
layer.shadowRadius =
} func commonInit() {
setImage(UIImage(named: self.imageURL)?.imageWithColor(self.color), forState: .Highlighted)
setImage(UIImage(named: self.imageURL), forState: .Normal)
} required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
} override func drawRect(rect: CGRect) {
super.drawRect(rect)
let path = UIBezierPath(ovalInRect: rect)
color.setFill()
path.fill()
} override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event) color = UIColor.whiteColor()
setNeedsDisplay() UIView.animateWithDuration(0.15) {
self.transform = CGAffineTransformMakeScale(0.9, 0.9)
}
} override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event) color = UIColor.orangeColor()
setNeedsDisplay() transform = CGAffineTransformMakeScale(0.0, 0.0) UIView.animateWithDuration(0.4, delay: , usingSpringWithDamping: 0.7, initialSpringVelocity: 0.5, options: [], animations: {
self.transform = CGAffineTransformIdentity
}, completion: nil)
} }

第七篇、使用UIView的animateWithDuration方法制作简易动画的更多相关文章

  1. 第七篇 :微信公众平台开发实战Java版之如何获取微信用户基本信息

    在关注者与公众号产生消息交互后,公众号可获得关注者的OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的.对于不同公众号,同一用户的openid不同). 公众号可通过本接口来根据O ...

  2. 第七篇 Integration Services:中级工作流管理

    本篇文章是Integration Services系列的第七篇,详细内容请参考原文. 简介在上一篇文章,我们创建了一个新的SSIS包,学习了SSIS中的脚本任务和优先约束,并检查包的MaxConcur ...

  3. 第七篇 SQL Server安全跨数据库所有权链接

    本篇文章是SQL Server安全系列的第七篇,详细内容请参考原文. Relational databases are used in an amazing variety of applicatio ...

  4. 用仿ActionScript的语法来编写html5——第七篇,自定义按钮

    第七篇,自定义按钮这次弄个简单点的,自定义按钮.其实,有了前面所定义的LSprite,LBitmap等类,定义按钮就很方便了.下面是添加按钮的代码, function gameInit(event){ ...

  5. UIView属性及方法

    @property(nonatomic) CGFloat alpha //设置视图的透明度 //透明度的设置从最小0.0到1.0 ,1.0为完全不透明, //其中这个属性只影响当前视图,并不会影响其子 ...

  6. Python之路【第七篇】:线程、进程和协程

    Python之路[第七篇]:线程.进程和协程   Python线程 Threading用于提供线程相关的操作,线程是应用程序中工作的最小单元. 1 2 3 4 5 6 7 8 9 10 11 12 1 ...

  7. [老老实实学WCF] 第七篇 会话

    老老实实学WCF 第七篇 会话 通过前几篇的学习,我们已经掌握了WCF的最基本的编程模型,我们已经可以写出完整的通信了.从这篇开始我们要深入地了解这个模型的高级特性,这些特性用来保证我们的程序运行的高 ...

  8. Python开发【第七篇】:面向对象 和 python面向对象进阶篇(下)

    Python开发[第七篇]:面向对象   详见:<Python之路[第五篇]:面向对象及相关> python 面向对象(进阶篇)   上一篇<Python 面向对象(初级篇)> ...

  9. 【译】第七篇 SQL Server安全跨数据库所有权链接

    本篇文章是SQL Server安全系列的第七篇,详细内容请参考原文. Relational databases are used in an amazing variety of applicatio ...

随机推荐

  1. HTTP请求头详解【转】

    http://blog.csdn.net/kfanning/article/details/6062118 HTTP由两部分组成:请求和响应.当你在Web浏览器中输入一个URL时,浏览器将根据你的要求 ...

  2. 汇编语言(学习笔记-----[bx]和loop)

    1.[bx]是什么??     和[0]有些类似,[0]表示内存单元,它的偏移地址是0      [bx]同样也表示一个内存单元,它的偏移地址在bx中,mov ax,[bx]  (字)   mov  ...

  3. jsp页面用el表达式获取枚举的code

    jsp页面用el表达式获取枚举的code <c:set var="D_BUSINESS" value="<%=DeptEnum.D_BUSINESS%> ...

  4. HttpClient 设置代理方式

    HttpClient httpClient = new HttpClient(); //设置代理服务器的ip地址和端口 httpClient.getHostConfiguration().setPro ...

  5. Cts框架解析(12)-ITargetPreparer

    測试开启前的设备系统准备工作. 接口 /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Ap ...

  6. [IOS]自定义长触屏事件

    写一个Demo来自定义一个长触屏事件,自定义长按手势. 实现步骤: 1.创建一个自定义手势类,命名为LongPressGestureRecognizer,在创建的时候继承UIGestureRecogn ...

  7. 判断IE中iframe完美加载完毕的方法

    转: var iframe = document.createElement("iframe"); iframe.src = "http://www.planabc.ne ...

  8. IDispatch接口 - GetIDsOfNames和Invoke(转)

    IDispatch接口是COM自动化的核心.其实,IDispatch这个接口本身也很简单,只有4个方法: IDispatch : public IUnknown { public: virtual H ...

  9. Windows下用Git下载android源码 转载

    http://my.oschina.net/jiadebin/blog/52631 1.首先你的电脑要安装好git,这个请参考git官网. 2.打开git命令窗口输入git clone http:// ...

  10. 如何删除google流氓扩展(强制安装,并且无权限删除)

    chrome现在也是流氓遍地跑, 没比IE安全到哪里. TubeAdblocKer 这个流氓扩展,强制安装,无法删除.google了一大堆方法,全部无效.祭出了filelocator这个神器之后,终于 ...