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 指导或者高级技巧文章,能你玩转这些小动效。

zip
swift-WCLShineButton类似太阳动画的button.zip 预估大小:40个文件
folder
WCLShineButton-master 文件夹
file
WCLShineButton.podspec 990B
file
.swift-version 3B
folder
WCLShineButton.xcodeproj 文件夹
folder
project.xcworkspace 文件夹
file
contents.xcworkspacedata 159B
folder
xcuserdata 文件夹
folder
wangchonglei.xcuserdatad 文件夹
file
UserInterfaceState.xcuserstate 144KB
folder
xcshareddata 文件夹
file
WorkspaceSettings.xcsettings 241B
file
IDEWorkspaceChecks.plist 238B
file
project.pbxproj 21KB
folder
xcuserdata 文件夹
folder
wangchonglei.xcuserdatad 文件夹
folder
xcschemes 文件夹
file
Demo.xcscheme 3KB
file
xcschememanagement.plist 772B
folder
xcshareddata 文件夹
folder
xcschemes 文件夹
file
WCLShineButton.xcscheme 3KB
folder
Demo 文件夹
file
ViewController.swift 2KB
folder
Assets.xcassets 文件夹
folder
AppIcon.appiconset 文件夹
file
Contents.json 2KB
folder
collect.imageset 文件夹
file
daily_bottom_collect_nor@2x.png 1KB
file
Contents.json 378B
file
daily_bottom_collect_nor@3x.png 2KB
file
Contents.json 62B
folder
collect#.imageset 文件夹
file
Contents.json 378B
file
daily_bottom_collect_sel@2x.png 841B
file
daily_bottom_collect_sel@3x.png 1KB
folder
Base.lproj 文件夹
file
Main.storyboard 14KB
file
Launch Screen.storyboard 4KB
file
AppDelegate.swift 2KB
file
Info.plist 1KB
file
README.zh.md 3KB
folder
WCLShineButton 文件夹
file
WCLShineLayer.swift 4KB
file
WCLShineClickLayer.swift 3KB
folder
WCLShineButton.bundle 文件夹
folder
resource 文件夹
file
like.png 2KB
file
heart.png 2KB
file
smile.png 3KB
file
star.png 2KB
file
WCLShineBundle.swift 2KB
file
WCLShineButton.swift 4KB
file
Info.plist 753B
file
WCLShineParams.swift 4KB
file
WCLShineAngleLayer.swift 8KB
file
LICENSE 1KB
file
.gitignore 236B
file
CODE_OF_CONDUCT.md 3KB
file
README.md 4KB
file
DemoGif.gif 474KB
zip 文件大小:552.08KB