【问题标题】:how do i change the size of UIImageView according to my animationImages as they are bigger than initial UIImage我如何根据我的动画图像更改 UIImageView 的大小,因为它们大于初始 UIImage
【发布时间】:2009-12-19 14:04:03
【问题描述】:

这是我的代码,我正在尝试拖放一张将在 touchesBegan 上进行动画处理的卡片,但动画图像大于触摸开始前的初始卡片图像。

如何更改 UIImageView 以适应 animateImages 大小?

cardAnimationArray 是一个包含 19 幅图像 xxx1.png、xxx2.png... 的数组,它们的大小各不相同。

cardMovedImage 是 19 张图片系列中的最后一张。 提前谢谢你!

- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
    CGPoint pt = [[touches anyObject] locationInView:self.superview];
    self.center = pt;


    self.animationImages = [NSArray arrayWithArray:cardAnimationArray];
    [cardAnimationArray release];
    [self setAnimationRepeatCount:1];
    self.animationDuration= 1;
    [self startAnimating];
    self.image = [UIImage imageNamed:cardMovedImageName];




}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
    CGPoint pt = [[touches anyObject] locationInView:self.superview];
    CGRect frame = [self frame];
    frame.origin.x += pt.x - self.center.x;
    frame.origin.y += pt.y - self.center.y;
    [self setFrame: frame];

}

【问题讨论】:

  • UIImageView 比我的 animationImages 小...

标签: iphone xcode iphone-sdk-3.0 xcode3.2


【解决方案1】:

self.clipsToBounds = NO;是解决办法

【讨论】:

    【解决方案2】:

    将缩放模式设置为“中心”

    【讨论】:

      【解决方案3】:

      哈哈,其实有一个简单的解决方案; 只需设置 self.clipsToBounds = NO;

      self 代表 UIImageView

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-01-16
        • 2012-05-21
        • 2015-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-15
        • 2013-03-05
        • 2020-05-04
        相关资源
        最近更新 更多