项目 logomove0114
AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
//登录动画执行完成后显示本处的背景图
let bgImageView = UIImageView()
//设置图片
bgImageView.image = UIImage(named: "bg0114-2")
//设置图片位置及尺寸
bgImageView.frame = CGRect(x: 0, y: 0, width: (window?.frame.width)!, height: (window?.frame.height)!)
//视图框加载到window
window?.addSubview(bgImageView)
return true
}
ViewController.swift
//
// ViewController.swift
// lggomove0114
//
// Created by Mac on 1/14/19.
// Copyright © 2019 wjb. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
//创建登录 logo,进入页面后动作——变小——变大 ,最终显示背景图
//创建图片框
let logoImageView = UIImageView()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//设置view的背景色
view.backgroundColor = UIColor.blue
//加载logo图片
logoImageView.image = UIImage(named: "logo0114")
//设置图片框大小
logoImageView.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
//重设图片框的中心点
// logoImageView.center.x = view.center.x
// logoImageView.center.y = view.center.y
//简写
logoImageView.center = view.center
//图片框添加到view
view.addSubview(logoImageView)
}
//扩展动画
override func viewDidAppear(_ animated: Bool) {
UIView.animate(withDuration: 2, animations: {
//logo变小
self.logoImageView.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
self.logoImageView.center = self.view.center
}) { (finshed) in
//logo变大
UIView.animate(withDuration: 2, animations: {
//logo变大
self.logoImageView.frame = CGRect(x: 0, y: 0, width: 10000, height: 10000)
self.logoImageView.center = self.view.center
//view 透明
self.view.alpha = 0
})
}
}
}