Skip to content

Instantly share code, notes, and snippets.

@orkoden
Created June 16, 2016 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orkoden/59ad4d67dff71d60a26da539d6f280b1 to your computer and use it in GitHub Desktop.
Save orkoden/59ad4d67dff71d60a26da539d6f280b1 to your computer and use it in GitHub Desktop.
# StackView Tips
## Performance hack
### Old hack
Use a UITableViewCell's contentview. The layout will not bubble up from here. Keeps all layout restriced to that view.
Then set frame of cell.
### New Hack
Use a UIStackView, but don't use arranged Stackviews.
It has a special layer.
Add views directly as subviews and add your own constraints.
## Debugging, General Tips
- Give identifiers to constraints
- Avoid changing constraints
- Don't use updateConstraints to throw away all constraints and add them again.
- Change constraints as little as possible
- Use `[UIView _layoutDebugginIdentifier]` to identify view. Don't ship this though!
# Fastest order for updating constraints
Order of constraint changes affects speed. This is the fastest order.
Do deactivation in this order, then activate in the same order.
1. Required inequlities
2. Required equalities
3. Optional inequlities
4. Optional equalities
5. Constant Changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment