Skip to content

JakubMazur/FMBMParallaxView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FMBMParallaxView

Complete UIImageView subclass with parallax scrolling created during the first world SwiftCrunch hackaton!

Gif with results

FMBMImageView example usage

class ExampleViewController: UIViewController, UIScrollViewDelegate {

    @IBOutlet var imageView: FMBMImageView
    @IBOutlet var scrollView: UIScrollView

    override func viewDidLoad() {
        super.viewDidLoad()

        imageView.clipsToBounds = true
        scrollView.contentSize = CGSizeMake(400, 400)
        scrollView.delegate = self
    }
    
    func scrollViewDidScroll(scrollView: UIScrollView!) {
        let deltaX = scrollView.contentSize.width - scrollView.frame.width
        let deltaY = scrollView.contentSize.height - scrollView.frame.height
        
        imageView.horizontalOffset = scrollView.contentOffset.y / deltaX
        imageView.verticalOffset = scrollView.contentOffset.x / deltaY
    }

}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages