仿新浪微博手机客户端呼出菜单
毛玻璃方法
- 使用苹果提供的 UIImage 分类,调用一下方法即可
- 也可以使用系统自带的 effect 控件,不过只支持 iOS8之后
- 步骤
- 先截屏
- 开启图形上下文
- 将 window 中的内容画到上下文中
- 取出图片
- 关闭上下文
- 返回数据
- 获取截取图片,设置效果
- 先截屏
关闭 button 的高亮效果
- 重写其 highlight 属性的 get 方法,一直返回 false
//重写高亮属性---使其被禁用
override var highlighted: Bool{
get{
return false
}
set{
}
}
button 向上弹跳
button 向下落
使用 pop 框架
func doAnimation(index:Int, btn:ComposeMenuButton, isPop:Bool){
//1.创建动画
let animation = POPSpringAnimation(propertyNamed: kPOPViewCenter)
//2.设置要到达的位置
//根据isPop判断是上弹还是下落
animation.toValue = NSValue(CGPoint: CGPointMake(btn.center.x, btn.center.y + (isPop ? -350 : 350)))
//3.设置弹性强度
animation.springBounciness = 10
//4.设置速度
animation.springSpeed = 8
//5.设置开始时间
animation.beginTime = CACurrentMediaTime() + Double(index) * 0.025
//5.添加动画
btn.pop_addAnimation(animation, forKey: nil)
}