UIView
作为toast的显示内容//UIView的分类,可直接在view上显示toast
[self.view makeToast:@"Something happen"
duration:0.5
position:HTToastPositionCenter
title:nil
image:[UIImage imageNamed:@"1-selected"]];
//显示
[self.view makeToastActivity];
[self.view makeToastActivityWithMessage:@"Message测试"];
//隐藏
[self.view hideToastActivity];
//其它扩展接口可自行使用
[self.view showToast:toastView];
//通过block来制作动画信息
- (void)showToast:(UIView *)toast
showWithAnimationBlock:(animationBlock)showAnimationBlock
hideWithAnimationBlock:(animationBlock)hideAnimationBlock;
//block参数是当前view以及需要显示的toast
[self.view showToast:toastView showWithAnimationBlock:^(UIView *view, UIView *toast) {
toast.alpha = 1;
CAKeyframeAnimation *showAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
showAnimation.duration = 0.4;
showAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.01f, 0.01f, 1.0f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1f, 1.1f, 1.0f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9f, 0.9f, 1.0f)],
[NSValue valueWithCATransform3D:CATransform3DIdentity]];
showAnimation.keyTimes = @[@0.2f, @0.5f, @0.75f, @1.0f];
showAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
showAnimation.delegate = self;
[toast.layer addAnimation:showAnimation forKey:nil];
} hideWithAnimationBlock:^(UIView *view, UIView *toast) {
//自定义
.....
}];
//显示在keyWindow上面
[HTToast showToastWithMessage:@"HTShowMessageOnWindow"];
[HTToast showToastWithView:toastView];
该项目最低支持iOS 7.0
和Xcode 7.0
HTToast,详见LICENSE文件。