码迷,mamicode.com
首页 > 编程语言 > 详细

Swift UINavigationController

时间:2017-10-20 10:09:14      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:any   交互   uiimage   over   win   var   ram   app   self   

import UIKit
import CoreData


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        
        
        self.window = UIWindow(frame:UIScreen.main.bounds);
        self.window?.backgroundColor = UIColor.red;
        let navagationVC = UINavigationController.init(rootViewController: ViewController());
        self.window?.rootViewController = navagationVC;
        self.window?.makeKeyAndVisible();
        
       
        return true
    }

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "我的主页";
        self.navigationController?.navigationBar.barTintColor = UIColor.blue;
        
        let image = UIImage.init(named: "111.png");
        let imageView = UIImageView();
        imageView.frame = CGRect.init(x: 100, y: 100, 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: 200, width: 200, height: 200);
        tap.view?.frame = frame!;
        
        
    }

}


Swift UINavigationController

标签:any   交互   uiimage   over   win   var   ram   app   self   

原文地址:http://www.cnblogs.com/laolitou-ping/p/7697657.html

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