iphone - 向相反方向调整 UIView 的大小
<p><p>当您调整 UIView 的大小时,宽度/高度会向右/向下增加。有没有办法让它走向相反的方向?我以为这可能是 <code>layer.anchorPoint</code> 可以实现的,但看起来不像。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>最快的方法是重新制作 View 的框架。</p>
<p>假设你想在“相反”方向将它的宽度和高度增加 10。</p>
<p>这样就可以了。</p>
<pre><code>view.frame = CGRectMake(view.frame.origin.x - 10, view.frame.origin.y - 10, view.frame.size.width + 10, view.frame.size.height + 10);
</code></pre>
<p>你可以把它放在一个更容易的方法中:</p>
<pre><code>-(void)inverseResizeView(UIView *)view width:(int)deltaWidth height:(int)deltaHeight{
view.frame = CGRectMake(view.frame.origin.x - deltaWidth, view.frame.origin.y - deltaHeight, view.frame.size.width + deltaWidth, view.frame.size.height + deltaHeight);
}
</code></pre></p>
<p style="font-size: 20px;">关于iphone - 向相反方向调整 UIView 的大小,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/8001906/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/8001906/
</a>
</p>
页:
[1]