[self.viewButtonsetTranslatesAutoresizingMaskIntoConstraints:NO];spa
//[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.viewButton attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];orm
//改變 高度server
[self.viewaddConstraint:[NSLayoutConstraintip
constraintWithItem:self.viewButtonit
attribute:NSLayoutAttributeHeightio
relatedBy:NSLayoutRelationEqualobject
toItem:self.viewview
attribute:NSLayoutAttributeHeightvi
multiplier:0.3ant
constant:0]];
[self.viewButtonaddObserver:selfforKeyPath:@"bounds"options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitialcontext:nil];//註冊kvo監聽bounds的變化
}
//kvo回調
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (object == self.viewButton && [keyPath isEqualToString:@"bounds"])
{
// [self.viewButton setTitle:NSStringFromCGSize(self.viewButton.bounds.size) forState:UIControlStateNormal];
NSLog(@"");
}
}