图片缩放

来源:互联网 发布:犀牛软件材质贴图 编辑:程序博客网 时间:2024/06/08 13:09

图片缩放默认是以中心点为缩放点,有时需要缩放点不是中心点,如右下角。

*-(void)setAnchorPoint:(CGPoint)anchorPoint forView:(UIView *)view{    CGPoint newPoint = CGPointMake(view.bounds.size.width * anchorPoint.x,                                   view.bounds.size.height * anchorPoint.y);    CGPoint oldPoint = CGPointMake(view.bounds.size.width * view.layer.anchorPoint.x,                                   view.bounds.size.height * view.layer.anchorPoint.y);    newPoint = CGPointApplyAffineTransform(newPoint, view.transform);    oldPoint = CGPointApplyAffineTransform(oldPoint, view.transform);    CGPoint position = view.layer.position;    position.x -= oldPoint.x;    position.x += newPoint.x;    position.y -= oldPoint.y;    position.y += newPoint.y;    view.layer.position = position;    view.layer.anchorPoint = anchorPoint;}*
0 0