码迷,mamicode.com
首页 > 移动开发 > 详细

iOS - Swift -UIimageView

时间:2019-11-19 15:42:36      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:set   view   ras   repeat   sed   fit   let   数组   ring   

//

//  ViewController.swift

//  Label

//

//  Created by 赵士军 on 2019/11/18.

//  Copyright © 2019 赵士军. All rights reserved.

//

 

import UIKit

 

class ViewController: UIViewController {

 

    override func viewDidLoad() {

        super.viewDidLoad()

  

        self.setupImageView()

    }

    func setupImageView() {

        //初始化一个imageView

        let firstImageView  = UIImageView.init(frame: self.view.frame)

        //设置imageView的图片

//        firstImageView.image = UIImage.init(named: "imagee")

         firstImageView.backgroundColor = .red

        firstImageView.contentMode = .scaleAspectFit

        //将Label添加到父self.view上来做显示

        self.view.addSubview(firstImageView)

    }

    

    func setupAnimationImageView() {

        //初始化一个imageView

        let firstImageView = UIImageView.init(frame: CGRect.init(x: 0, y: 0, width: 251, height: 375))

        //设置imageView的中心位置

        firstImageView.center = self.view.center

        //获取图片序列数组

        let imagesArray = NSMutableArray.init()

        //数组中添加Images

        for i in 1...10 {

            let image = UIImage.init(named: String.init(format: "firas%d", i))

            

            imagesArray.add(image as Any)

        }

        //设置动画数组

        firstImageView.animationImages = imagesArray as? [UIImage]

        

        //设置动画时长

        firstImageView.animationDuration = 1.2

        //设置动画播放次数,0表示无限次

        firstImageView.animationRepeatCount = 0

        //开始动画

        firstImageView.startAnimating()

        //将Label添加到父self.view上来做显示

        self.view.addSubview(firstImageView)

    }

 

    /*

    // MARK: - Navigation

 

    // In a storyboard-based application, you will often want to do a little preparation before navigation

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

        // Get the new view controller using segue.destination.

        // Pass the selected object to the new view controller.

    }

    */

 

}

 

iOS - Swift -UIimageView

标签:set   view   ras   repeat   sed   fit   let   数组   ring   

原文地址:https://www.cnblogs.com/ZsjXxy/p/11889665.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!