移动时调整 UIButton 上的 imageView 大小
在我的应用程序中,我对对象进行了概述。每个对象都是一个UIButton,它有自己的UIImage(button.imageView)。用户可以拖动对象。因此,显示器上部的对象被认为是“在后面”,而下部的对象被认为是“在前面”。后面的对象显示得比前面的对象小。我希望对象在从“前”到“后”移动时动态调整大小,反之亦然。
为此,我使用以下代码(在 UIButton 的子类中):
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
CGFloat h = newHeight;
CGFloat w = newWidth;
CGRect target;
target.size.height = h;
target.size.width = w;
self.frame = target;
}
在 iOS 4.2 之前,该代码运行得非常好。现在我们看到非常奇怪的行为:虽然在将对象从“前”移动到“后”(即从大到小)时调整大小有效,但在将对象从“后”移动到“前”(即从大到小)时它不起作用由小到大)。
知道什么可能导致这个问题吗?您将如何实现“移动时调整大小”?
In my application I have an overview of objects. Each object is a UIButton, which has its own UIImage (button.imageView). The user can drag objects around. Thereby, objects in the upper part of the display are considered to be 'in the back' while objects in the lower part are 'in the front'. Objects in the back are displayed smaller than objects in the front. I want the objects to dynamically resize while moving from 'front' to 'back' and vice-versa.
For this purpose, I use the following code (in a subclass of UIButton):
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
CGFloat h = newHeight;
CGFloat w = newWidth;
CGRect target;
target.size.height = h;
target.size.width = w;
self.frame = target;
}
This was working very nice up until iOS 4.2. Now we see very strange behaviour: while the resizing works when moving objects from 'front' to 'back' (i.e., from large to small), it DOES NOT work when moving object from 'back' to 'front' (i.e., from small to large).
Any idea what could cause this problem? How would you implement the 'resize while moving'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论