• Swift UIImageView常用方法


    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, 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, 300, height: 300);
            tap.view?.frame = frame!;
            
            
        }

    }
    详细代码查看:https://github.com/xiaolitou-ping/Swift-All

  • 相关阅读:
    信令基本概念
    CMMI
    关于OpenDataSource, OpenRowSet
    冒泡排序
    使用Sqlldr向oracle导入数据
    PowerDesigner生成sql和反向工程生成ER图的问题
    2021.1.4 学习总结
    12天 —— 关于生活与目标的思考【2020.8.5~2020.8.17】
    大一暑假学习总结(七)【2020.7.28~2020.8.4】
    学习:用javascript增加、删除行(转)
  • 原文地址:https://www.cnblogs.com/laolitou-ping/p/7691453.html
Copyright © 2020-2023  润新知