I am trying to use the new Auto Layout in Lion because it seems quite nice. But I can not find good information about how to do things. For example:
I have two labels:>
One simple solution is to just subclass UILabel and change the intrinsic content size.
@implementation WBSCollapsingLabel
- (CGSize)intrinsicContentSize
{
if (self.isHidden) {
return CGSizeMake(UIViewNoIntrinsicMetric, 0.0f);
} else {
return [super intrinsicContentSize];
}
}
- (void)setHidden:(BOOL)hidden
{
[super setHidden:hidden];
[self updateConstraintsIfNeeded];
[self layoutIfNeeded];
}
@end