iOS开发中一些手写控件及其相关属性的使用

2020-01-14 18:48:47王振洲

            center.x-=50;
            break;
        case krightbtntag:
            center.x+=50;
            break;
    }
    
 //  self.headImageView.frame=frame;
    
    //首尾式设置动画效果
    [UIView beginAnimations:nil context:nil];
    self.headImageView.center=center;
    //设置时间
    [UIView setAnimationDuration:2.0];
    [UIView commitAnimations];
    NSLog(@"移动!");
    
}
-(void)Zoom:(UIButton *)btn
{
    //使用frame,以自己的左上角(自己的原点)为原点
//    CGRect frame=self.headImageView.frame;
//    if (btn.tag) {
//        frame.size.height+=30;
//        frame.size.width+=30;
//    }
//    else
//    {
//        frame.size.width-=50;
//        frame.size.height-=50;
//    }
//    self.headImageView.frame=frame;
    
    
    //使用bounds,以中心点位原点进行缩放
    CGRect bounds = self.headImageView.bounds;
    if (btn.tag) {
        bounds.size.height+=30;
        bounds.size.width+=30;
    }
    else
    {
        bounds.size.height-=50;
        bounds.size.width-=50;
    }
    
    //设置首尾动画
    [UIView beginAnimations:nil context:nil];
    self.headImageView.bounds=bounds;
    [UIView setAnimationDuration:2.0];
    [UIView commitAnimations];
}
@end


实现效果:

 

iOS开发中一些手写控件及其相关属性的使用