Swift/IOS Views and Drawing

The flashcards below were created by user geschw66 on FreezingBlue Flashcards.

  1. CGPoint
    • location in space:{ x , y }
    • – sometimes used as an origin
  2. CGSize
    – dimensions: { width , height }
  3. CGRect
    location and dimension: { origin , size }
  4. Example of creating a CGPoint
    var point = CGPoint(x: 100.0, y: 200.0)

    point.x = 300.0

    point.y = 30.0
  5. Example of creating a CGSize
    var size = CGSize(width: 42.0, height: 11.0);

    size.width = 100.0;

    size.height = 72.0;
  6. Example of creating a CGRect
    var rect = CGRect (x:100.0, y: 200.0, width: 42.0,height: 11.0);


    rect.origin.x = 0.0;

    rect.size.width = 50.0
  7. UIView Coordinate System: The origin is in the __?__ corner
    upper left
  8. UIView Coordinate System: y axis grows __?___
    downwards
  9. UIView Coordinate System: Units are __?__, not pixels
    points
  10. UIView Coordinate System: Points are units of __?__
    coordinate system
  11. UIView Coordinate System: Pixels are __?__ size unit of drawing
    min size unit of drawing
  12. UIView Coordinate System: Typically_?_ pixels per point
    2 pixels per point
  13. Location and Size: Two ways location and size are expressed.
    (1) Frame is in superview’s coordinate system

    (2)Bounds is in local coordinate system
  14. Location and Size:__?__ is in superview’s coordinate system
    Frame
  15. Location and Size: __?__ is in local coordinate system
    Bounds
  16. Frame and Bounds: Use of one of these depends on ___?___
    context
  17. Frame and Bounds: If you are using a view, typically you use __?__.
    frame
  18. Frame and Bounds: If you are implementing a view, typically you use___?___
    bounds
  19. Frame and Bounds: Two examples of using a frame?
    Creating a view, positioning a view in superview - use frame (perspective outside)
  20. Frame and Bounds: Two examples of using bounds?
    Handling events, drawing a view- use bounds (perspective inside)
  21. Views: Are commonly placed in __?__
    Storyboard
  22. Views:Views are initialized using
    UIView.init(frame: )
  23. Manual Creation of a View; example:
    let theFrame = CGRect(x:0, y:0, width:200, height:150);

    let myView = UIView.init(frame: theFrame)
  24. Manual Creation of a Label; example:
    let frame = CGRect(x:20, y:45, width: 140, height: 20)

    let myLabel = UILabel.init(frame: frame)

    myLabel.text = “Hello Class”
  25. Defining Custom Views: Three steps:
    (1) Subclass UIView

    (2) For custom drawing, you override: func drawRect(_ rect: CGRect)

    (3) For event handling, you override: the touchesBegan, touchesMoved and touchesEnded function.
  26. drawRect: Method: does nothing by default– If not overridden, then backgroundColor is used to fill(T/F).
    TRUE
  27. Override – drawRect: to draw a custom view – rect argument is __?__
    area to draw
Author
ID
321770
Card Set
Swift/IOS Views and Drawing
Description
Based off of slide and lectures from the CSE 428a Mobile Application Development class at Washington University At St. Louis Summer of 2016, Todd Spruill; Instr.
Updated
Show Answers