ios个推如何让消息弹框消失,或者自定义?
发布网友
发布时间:2023-10-10 09:25
我来回答
共1个回答
热心网友
时间:2024-12-05 11:57
在iOS中,系统再带的弹出窗体不好扩展,开发时候不如自定义一个弹出窗体,附加上显示和消失的动画。
弹出窗体父类如下,具体效果直接往上面添加控件就行。 // // ViewController.swift // NoahSalesManage // // Created by Administrator on 15/3/5. // Copyright (c) 2015年 cdwlb-zhangzhengfa. All rights reserved. //
import UIKit
class BounceView:UIControl {
var contentView:UIControl?;
override init(frame: CGRect) {
super.init(frame: frame)
self.processInterface()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.processInterface()
}
func processInterface()
{
self.backgroundColor = UIColor(white: 0, alpha: 0.8)
self.contentView = UIControl(frame: CGRectInset(self.frame, 20, 40))
self.contentView!.backgroundColor = UIColor.whiteColor()
self.addSubview(self.contentView!)
self.alpha = 0
self.contentView!.transform = CGAffineTransformMakeScale(0.1, 0.1);
}
func showWithAnimation(animation:Bool)
{
if !animation
{
self.alpha = 1
}
else
{
UIView.animateWithDuration(0.5, delay: 0, options: .CurveEaseInOut, animations: { () -> Void in
self.alpha = 1
self.contentView!.transform = CGAffineTransformIdentity
}, completion: { (succss) -> Void in
})
}
}
func hideWithAnimation(animation:Bool)
{
if !animation
{
self.alpha = 1
}
else
{
UIView.animateWithDuration(0.5, animations: { () -> Void in
self.alpha = 0
self.contentView!.transform = CGAffineTransformMakeScale(0.1, 0.1)
})
}
}
}