WCLShineButton Swift发光动画按钮
太阳升起效果的按钮控件,WCLShineButton 在 Swift 里真的挺有意思的。它不是那种单调的点击反馈,而是用动画营造出一种小太阳在发光的感觉,视觉反馈强烈。你如果想给按钮增加点小动效,让用户一眼看到哪里能点,这个控件还蛮适合的。
WCLShineButton是对UIButton
的一个扩展,背后用的是Core Animation。简单来说,就是通过调节透明度、大小、位置,再加上一点CAKeyframeAnimation
的魔法,把普通的按钮变得更灵动。关键是,它写得挺简洁,集成也不复杂。
你只要把WCLShineButton.swift
拖进项目里,像普通按钮那样用就行。支持startShining()
和stopShining()
,可以根据用户点击动态切换状态。比如下面这段代码:
let shineButton = WCLShineButton(frame: CGRect(x: 100, y: 150, width: 100, height: 44))
shineButton.setTitle("点击我", for: .normal)
shineButton.setTitleColor(.white, for: .normal)
shineButton.backgroundColor = .systemBlue
shineButton.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
view.addSubview(shineButton)
你要是想在 CTA 按钮上吸引用户注意,这种太阳发光的动效真的挺抓眼的。适合做一些“收藏”、“点赞”之类需要反馈感强的操作。
如果你还不熟 Core Animation,推荐看看Core Animation 指导或者高级技巧文章,能你玩转这些小动效。
swift-WCLShineButton类似太阳动画的button.zip
预估大小:40个文件
WCLShineButton-master
文件夹
WCLShineButton.podspec
990B
.swift-version
3B
WCLShineButton.xcodeproj
文件夹
project.xcworkspace
文件夹
contents.xcworkspacedata
159B
xcuserdata
文件夹
wangchonglei.xcuserdatad
文件夹
UserInterfaceState.xcuserstate
144KB
xcshareddata
文件夹
552.08KB
文件大小:
评论区