Swift的渐变动画效果 – Shift

weixin_38087237 2019-09-12 01:53:53
Shift Shift allows you to do gradient color animations on your UI using either a timed animation or the device tilting motion. You can also easily mask the gradient animation to images or text. Couple this with the motion based animation and you will get an effect similar to the Robinhood app. Example To run the example project, clone the repo, and runpod installfrom the Example directory first. let view = ShiftView() // set colors view.setColors([UIColor.orange, UIColor.red, UIColor.blue, UIColor.purple]) // set animation duration view.animationDuration(3.0) // start animation view.startTimedAnimation() You can also start a motion based animation. The device accelerometer is used to shift the color as the device is tilted. Note that accelerometers are not available is the simulator. view.startMotionAnimation() You can instantate a Button and animate the gradient color on the text only This is similar to the gold reflection animations in the Robinhood app let button = ShiftButton() button.setTitle("Hello!", for: .normal) // Custom gradient direction button.start(shiftPoint: .topLeft) button.end(shiftPoint: .bottomRight) // Show the gradient on the text only button.maskToText = true button.startMotionAnimation() Here is a list of available UI Classes ShiftView() // maskable to text or image ShiftButton() ShiftLabel() // Maskable to text ShiftMaskableLabel() ShiftTextfield() ShiftTextView() // Maskable to image ShiftImageView() Each UI class has an Objective-C exuivalend, just add _Objc to the class name, ShiftView_Objc Requirements Swift 3.0, iOS 8. Compatible with Obj-c Installation Shift is available through CocoaPods . To install it, simply add the following line to your Podfile: pod "Shift"
...全文
20 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧