What is the difference between addSubview
and insertSubView
methods when a view is added programmatically?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- Can not export audiofiles via “open in:” from Voic
- How to get a CGImageRef from Context-Drawn Images?
I don't think there is a difference.
addSubview:
is simple a convenient method for1.addSubview add subview in array then add in View'slayer
}
2.While insertSubview add your view as subview then call
[_layer insertSublayer:subview.layer atIndex:index];
The only difference is in where the view is added: whether it is the frontmost view (
addSubview:
), or it is before the 5th subview, (insertSubview:atIndex:
) or if it is immediately behind another subview (insertSubview:aboveSubview:
).Using
insertSubView:
you can specify the index, which determines z-order of views. A view with a higher index lies above those with lower indices.