簡體   English   中英

我如何根據我的animationImages更改UIImageView的大小,因為它們大於初始UIImage

[英]how do i change the size of UIImageView according to my animationImages as they are bigger than initial UIImage

這是我的代碼,我試圖拖放將在touchesBegan上動畫的卡片,但是animationImages大於觸摸開始之前的初始卡片圖像。

如何更改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];

}

self.clipsToBounds = NO; 是解決方案

將縮放模式設置為“居中”

哈哈,實際上有一個簡單的解決方案。 只需設置self.clipsToBounds = NO;

其中self代表UIImageView

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM