CGAffineTransformation设置锚点吗? [英] CGAffineTransformation set the anchor?

查看:61
本文介绍了CGAffineTransformation设置锚点吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇.在我的应用程序中,我正在运行一个动画,在其中对视图进行了一些调整.我正在创建这样的转换:

I'm curious about something. In my app I'm running an animation where a view is resized a little bit. I'm creating the transform like this:

CGAffineTransform resize = CGAffineTransformMakeScale(0.8, 0.8);

但是,当我将此转换应用于视图并观看其运行时,它会从顶部调整大小并向底部缩小.我想要的是它在各个方向上均等地调整大小并向中心收缩的位置,就像锚点"位于中心一样.你知道我在说什么?这可能吗?

However, when I apply this transformation to my view and watch it run, it resizes from the top and shrinks towards the bottom. What I'm wanting is where it resizes evenly on all sides and shrinks towards the center, as if an "anchor" point is in the center. You know what I'm saying? Is this possible?

推荐答案

首先应用 CGAffineTransformMakeTranslation 将原点移动到中心-使用 CGAffineTransformConcat将它们合成为单个转换

First apply a CGAffineTransformMakeTranslation to move the origin to the center -- composite them into a single transform with CGAffineTransformConcat

这篇关于CGAffineTransformation设置锚点吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆