标签:ios
(没有逐字逐词翻译,希望能够理解,如果有不对的,恳请指正)
UIButton
subview
when the button is not in the window hierarchy will need to send layoutIfNeeded
to
the button before retrieving layout information (such as button.titleLabel.frame
) to ensure that the
layout values are up to date.For example, if you had something like this:
举例如下,如果iOS8.3以前,你这样写代码:
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; |
// code that sets up the button, but doesn’t yet add it to a window |
CGRect titleFrame = button.titleLabel.frame; |
// code that relies on the correct value for titleFrame |
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; |
// code that sets up the button, but doesn’t yet add it to a window |
[button layoutIfNeeded]; // This is also safe pre-iOS 8.3
|
CGRect titleFrame = button.titleLabel.frame; |
// code that relies on the correct value for titleFrame |
iOS SDK Release Notes for iOS 8.3 Beta 4 节选(UIKit)
标签:ios
原文地址:http://blog.csdn.net/workresource/article/details/45071081