如题,我prestioncontroller view后,我的image 直接出现在 动画结束的地方
而,这个 动画的方法 ,在其他的地方是可以作用的
是不是我应该写在某一个delete 里,或是,我写错 事件了??
初始 的code
let loveViewController:LoveViewController!
loveViewController = LoveViewController();
loveViewController.refreshWithFrame(CGRectMake(0,0,frameWidth,frameHeight))
self.mainVC.presentViewController(loveViewController, animated: true, completion: nil)
viewcontroll的code
class LoveViewController: UIViewController {
var MyFunc:myFunc!
var toolBar:ToolBar!
var loveNavigationBar:UIView!
func refreshWithFrame(frame:CGRect){
self.view = UIView(frame: UIScreen.mainScreen().bounds)
self.view.backgroundColor = UIColor.whiteColor()
MyFunc = myFunc()
toolBar = ToolBar(frame: CGRectMake(0,frameHeight - frameHeight/10 ,frameWidth,frameHeight/10),page: "myheart")
toolBar.mainVC = self
//toolBar.page = "myheart"
self.view.addSubview(toolBar)
loveNavigationBar = UIView(frame: CGRectMake(0,0,frameWidth,frameHeight/10))
loveNavigationBar.backgroundColor = MyFunc.colorHex("#ff69b4")
self.view.addSubview(loveNavigationBar)
let navigationBarTitleLabel:UILabel = UILabel(frame: CGRectMake(loveNavigationBar.frame.size.width / 2 - 50 , 20,100,30))
navigationBarTitleLabel.center = loveNavigationBar.center
navigationBarTitleLabel.textColor = UIColor.whiteColor()
navigationBarTitleLabel.backgroundColor = UIColor.clearColor()
navigationBarTitleLabel.text = "我的收藏"
navigationBarTitleLabel.textAlignment = .Center
loveNavigationBar.addSubview(navigationBarTitleLabel)
if LoveDictionary.count == 0 {
showNillView()
}
}
func showNillView(){
//以下是动画的code
let heart:UIImageView = UIImageView(frame: CGRectMake(frameWidth / 2 - 50, frameHeight / 10 * 2, 100, 100))
let heart_2:UIImageView = UIImageView(frame: CGRectMake(frameWidth / 2 - 50, frameHeight / 10 * 2, 100, 100))
heart.image = UIImage(named: "bigheart")
heart_2.image = UIImage(named: "bigheart_2")
heart_2.alpha = 0
self.view.addSubview(heart)
self.view.addSubview(heart_2)
UIView.beginAnimations("", context: nil)
UIView.setAnimationDuration(1)
print(111)
heart.frame.origin.y = 300
//heart.frame.size = CGSize(width: 100, height: 100)
UIView.commitAnimations()
}
loveViewController.refreshWithFrame(CGRectMake(0,0,frameWidth,frameHeight))
写在
LoveViewController
的viewDidAppear
里面最好self.refreshWithFrame(CGRectMake(0,0,frameWidth,frameHeight))
创建controller了的时候view还没加载出来呢