[self.viewButtonsetTranslatesAutoresizingMaskIntoConstraints:NO];
//[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.viewButton attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];
//改变 高度
[self.viewaddConstraint:[NSLayoutConstraint
constraintWithItem:self.viewButton
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeHeight
multiplier:0.3
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(@"");
}
}