首页 > 编程语言 > 详细

Swift UIImageView常用方法

时间:2017-10-19 11:36:03      阅读:311      评论:0      收藏:0      [点我收藏+]

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
       
        let image = UIImage.init(named: "111.png");
        
        let imageView = UIImageView();
        imageView.frame = CGRect.init(x: 100, y: 10, width: 200, height: 200);
        imageView.image = image;
        self.view.addSubview(imageView);
        //圆角
        imageView.layer.masksToBounds = true;
        imageView.layer.cornerRadius = 100;
        imageView.layer.borderColor = UIColor.orange.cgColor;
        imageView.layer.borderWidth = 2
        imageView.clipsToBounds = true;
        //交互
        imageView.isUserInteractionEnabled = true;
        let tap = UITapGestureRecognizer.init(target: self, action:#selector(ViewController.tapAction));
        imageView.addGestureRecognizer(tap);
        //设置拉伸模式
        imageView.contentMode = UIViewContentMode.scaleAspectFill;
    
        
    }
    func tapAction(tap:UITapGestureRecognizer) {

        var frame = tap.view?.frame;
        
        frame = CGRect.init(x: 100, y: 100, width: 300, height: 300);
        tap.view?.frame = frame!;
        
        
    }

}

Swift UIImageView常用方法

原文:http://www.cnblogs.com/laolitou-ping/p/7691453.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!