Giter VIP home page Giter VIP logo

swift-scrollviews-lab-ios-0916's Introduction

ScrollView Fun

BingBong

Take her to the moon for me. Okay? -Bing Bong

Learning Objectives

  • Create a UIScrollView in Storyboard
  • Properly constrain the UIScrollView to the UIView
  • Create a UIStackView in Storyboard
  • Properly constrain the UIStackView in the UIScrollView to allow for horizontal scrolling

Instructions

  • Included in this Xcode project is the following images:

movie

  • It is your job to create an app that can scroll from left to right (in a page-like manner) through these various characters. Each image (while displayed) should take up the full width & height of the iPhone.

  • In Storyboard, create a UIScrollView and constrain it to the edges of the View.
  • In Storyboard, create a UIStackView, we want to be able to scroll horizontally.. so which one do you think we should choose? Our options are Horizontal or Vertical. Even if you feel you chose the wrong one, you can change it from Horizontal <--> Vertical in the attributes inspector:

attributes

  • Before we move any further. I mentioned that this app should let us scroll from left to right in a page-like manner. Is there a property we're forgetting to set in the Attributes Inspector on our UIScrollView?
  • How should we constrain the UIStackView? At this stage, you can make an attempt yourself to see if you can figure it out all by your lonesome or you can continue reading. I recommend making an attempt yourself and failing at it.. or possibly succeeding!

  • Skip this section if you made an attempt at producing the constraints for the UIStackView yourself.
  • First you need to constrain the UIStackView to the edges of its parent view. Its parent view is the UIScrollView.
  • Against what feels normal for you when making constraints, we need to set a Height & Width constraint on the UIStackView. Think of the UIScrollView as a fixed window that we're peering into it and its content (its content being the UIStackView) is what's inside that window. That content can be larger than the window, we can move the window from side to side and while it's moving we can only see what's visible through the window.

appleKid

  • This image is a better representation of the prior bullet point. The black box is the UIScrollView and the photo of the boy is the content. We can move the window around to view the content.
  • So all of that out of the way, we setup our window UIScrollView (sticking with the analogy) to be constrained to the View. We need to set the height & width of this UIStackView, which in this analogy is the photo of this boy.
  • The height should be set to equal the height of the View. This is so we can't scroll up & down, we only want to scroll left and right.
  • We have 5 photos we need to add to this UIStackView, what should the width of this UIStackView be set to? In setting up the width constraint equal to the View, you should set the multiplier equal to something other than 1.
  • It might be hard to guess exactly how your UIStackView should be laid out, but make an attempt at setting the correct attributes before adding the UIImageView's below. It might be hard to guess right the first time.. but don't just guess. Make an attempt to think through what you're setting here.

stackAttributes


  • Add five(5) UIImageView's to your UIStackView
  • Set a separate image into each UIImageView. The images are included in the project for you.
  • UIImageView's has a property which dictates how the UIImage will fill within its space, mess around with the various options to see what looks best.

imageViewOptions

  • There are other options as well on UIImageView. The UIImageView acts like the picture frame to your UIImage. This can help you out in a situation where you might see some images bleeding over its frame (picture frame). Mess around here to see how you can fix that problem:

moreOptions


  • Word of advice when working with UIScrollView's. Run and run often.

yay

View this lesson on Learn.co

swift-scrollviews-lab-ios-0916's People

Contributors

bensu1013 avatar jimcampagno avatar susanlovaglio avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.