- (void)button {
UIButton *button = [[UIButton alloc]init];
button.bounds = CGRectMake(0, 0, 200, 200);
button.center = self.view.center;
button.backgroundColor = [UIColor grayColor];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
button.layer.anchorPoint = CGPointMake(0, 0);
NSLog(@"anchorpoint = %@ center = %@",
NSStringFromCGPoint(button.layer.anchorPoint),
NSStringFromCGPoint(button.center));
}
点击事件:
#pragma mark - buttonPressed
- (void)buttonPressed:(UIButton *)sender {
[UIView animateWithDuration:0.5 animations:^{
//绕着锚点旋转
// sender.transform = CGAffineTransformRotate(sender.transform, M_PI_2);
//放大,不是中心放大
sender.transform = CGAffineTransformScale(sender.transform, 1.2, 1.2);
}];
}