IOS 创建动画提示框
2015-10-08 16:22
399 查看
h文件
#import <UIKit/UIKit.h> @interface UILabel (Message) +(void)showMessage:(NSString *)message inView:(UIView *)aView; @end
m文件
#import "UILabel+Message.h" @implementation UILabel (Message) +(void)showMessage:(NSString *)message inView:(UIView *)aView{ UILabel *label = [[UILabel alloc] init]; label.text = message; [label sizeToFit]; label.center = aView.center; label.backgroundColor = [UIColor blackColor]; label.alpha = 0; label.textAlignment = NSTextAlignmentCenter; label.textColor = [UIColor whiteColor]; label.font = [UIFont systemFontOfSize:13]; label.layer.cornerRadius = 6; [aView addSubview:label]; [UIView animateWithDuration:1.5 animations:^{ label.alpha = 1.0; } completion:^(BOOL finished) { [UIView animateWithDuration:2.0 animations:^{ label.alpha = 0; }completion:^(BOOL finished) { [label removeFromSuperview]; }]; }]; } @end在需要的文件里,引入文件
在方法里添加:
[UILabel showMessage:@"提示内容" inView:self.view];
注:@“”为自定义内容
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- Gifski:一个跨平台的高质量 GIF 编码器
- 模仿动画的放大缩小容器
- jQuery实现美观的多级动画效果菜单代码
- php判断GIF图片是否为动画的方法
- jQuery实现动画效果circle实例
- 浅析JavaScript动画
- js排序动画模拟-插入排序
- javascript+HTML5的Canvas实现Lab单车动画效果
- js实现按钮颜色渐变动画效果
- 在ASP.NET使用JavaScript显示信息提示窗口实现原理及代码
- jQuery实现信息提示框(带有圆角框与动画)效果
- jQuery实现带有洗牌效果的动画分页实例
- jquery实现先淡出再折叠收起的动画效果