苹果官方Toast Demo关键代码,Swift实现
2017-10-27 11:30
1081 查看
显示部分
func showToast(_ text: String) {
label.text = text
guard toast.alpha == 0 else {
return
}
toast.layer.masksToBounds = true
toast.layer.cornerRadius = 7.5
UIView.animate(withDuration: 0.25, animations: {
self.toast.alpha = 1
self.toast.frame = self.toast.frame.insetBy(dx: -5, dy: -5)
})
}
隐藏部分
func hideToast() {
UIView.animate(withDuration: 0.25, animations: {
self.toast.alpha = 0
self.toast.frame = self.toast.frame.insetBy(dx: 5, dy: 5)
})
}
func showToast(_ text: String) {
label.text = text
guard toast.alpha == 0 else {
return
}
toast.layer.masksToBounds = true
toast.layer.cornerRadius = 7.5
UIView.animate(withDuration: 0.25, animations: {
self.toast.alpha = 1
self.toast.frame = self.toast.frame.insetBy(dx: -5, dy: -5)
})
}
隐藏部分
func hideToast() {
UIView.animate(withDuration: 0.25, animations: {
self.toast.alpha = 0
self.toast.frame = self.toast.frame.insetBy(dx: 5, dy: 5)
})
}
相关文章推荐
- swiper实现今日头条导航效果,在官方demo实现全部代码
- Tensorflow在Android上的实现(一)Build官方Demo
- Welcome to Swift (苹果官方Swift文档初译与注解三十)---219~224页(第四章-- 流程控制 完)
- ios开发 设备录音 音频流的 获取 ACC PCM 等都可以 苹果官方提供的 demo下载链接
- iOS 苹果官方Demo合集
- 安装xcode6 beta 后调试出现Unable to boot the iOS Simulator以及编译苹果官方Swift的demo报错failed with exit code 1的解决办法
- 一步步实现滑动验证码,Java图片处理关键代码
- 关键路径的实现C++ 代码
- Swift实现断点续传,Demo简单易懂,没有太多复杂模块和逻辑,完整体现断点续传的原理
- Kafka 0.11.0.0 实现 producer的Exactly-once 语义(官方DEMO)
- Swift3.0剪切板代码拷贝及跨应用粘贴实现代码
- ReactiveSwift源码解析(九) SignalProducerProtocol延展中的Start、Lift系列方法的代码实现
- 高德地图的Js API 简单Demo,可以快速实现路点描线(摘自官方接口及自行修改测试)
- 使用Swift实现SpriteKit游戏Demo
- Swift实现糗事百科Demo(实战项目)
- 在程序中使用代码打开苹果自带的地图并实现导航
- Swift - 纯代码实现页面segue跳转,以及参数传递
- iOS实现短信发送代码---简单demo
- jQuery实现的超酷苹果风格图标滑出菜单效果代码
- 苹果官方demo