Skip to content

Instantly share code, notes, and snippets.

@lin
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save lin/134ecc83c81adcce850f to your computer and use it in GitHub Desktop.

Select an option

Save lin/134ecc83c81adcce850f to your computer and use it in GitHub Desktop.
Learning iOS basic

1, container relationships

Screen has window, window has viewController (root), vC has view, view has subview

2,

// Both UIView and UIViewController is a UIResponder
touchesBegan:withEvent:

3,

Views and windows present your application’s user interface and handle the interactions with that interface.

4,Explains uiview and calayer

Every UIView comes packaged with a CALayer knows as the “backing layer” or “underlying layer.” Many of the methods you call on UIView simply delegate to the layer. When you change a view’s frame, it’s simply changing the layer’s frame. If you change the alpha, it changes the layer’s alpha…and so on with background colors, transformations and more

5,

Macros are compile time constants. That means they will replaced with actual values in the compile time.

Life cycle

1, loadView
2, viewDidLoad
1, view.backgroundColor
2, view.alpha

1, [view addSubview]
2, [view setContentMode:UIViewContentModeScaleAspectFit]

UIButton is a UIControl, UIControl is a UIView

1, properties

button.frame
button.setTitle("Button Title", forState: UIControlState.Normal)
[button removeFromSuperview]
button.titleLabel is a UILabel

2, controls

addTarget:action:forControlEvents:

[firstButton addTarget:self
action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];

UIControlEventTouchDown
UIControlEventTouchDownRepeat
UIControlEventTouchDragInside
UIControlEventTouchDragOutside
UIControlEventTouchDragEnter
UIControlEventTouchDragExit
UIControlEventTouchUpInside
UIControlEventTouchUpOutside
UIControlEventTouchCancel
UIControlEventValueChanged
UIControlEventEditingDidBegin
UIControlEventEditingChanged
UIControlEventEditingDidEnd
UIControlEventEditingDidEndOnExit
UIControlEventAllTouchEvents
UIControlEventAllEditingEvents
UIControlEventAllEvents 

1, properties

lable.text
lable.backgroundColor
UITabBarController
[tabBarController setViewControllers:@[feedViewController, favoritesViewController]];
feedViewController.tabBarItem.image
[UIImage imageNamed:@"tab_icon_feed"]
UITextView
textView.text
textView.font
textView.editable
self.scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight
self.scrollView.contentSize = CGSizeMake(320, 480)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment