Wednesday, 8 March 2017

UIScrollView : Dynamic




//
//  ViewController.swift
//  TestApp2
//
//  Created by Divakar Singh on 3/7/17.
//  Copyright (c) 2017 Divakar Singh. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
   
    var scrollView: UIScrollView!
    var imageView: UIImageView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        imageView = UIImageView(image: UIImage(named: "image1.png"))
        
        scrollView = UIScrollView(frame: view.bounds)
        scrollView.backgroundColor = UIColor.blackColor()
        scrollView.contentSize = imageView.bounds.size
        scrollView.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
        // FOR SET CONTENT/IMAGE POSITION, CURRENT (0,0)
          scrollView.contentOffset = CGPoint(x: 500, y: 450)
        scrollView.addSubview(imageView)
        view.addSubview(scrollView)
    }

    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

No comments:

Post a Comment