iphone - 将多个 UIImages 插入到 "container"

标签 iphone objective-c ios animation uiimageview

我想知道是否可以将多个图像插入到 objective-c 中的“容器”中。

例如,如果我有前轮、后轮和车身的图像。我可以将这些都放在一个容器中,这样当我移动或变换(缩放、旋转)容器时,里面的所有图像都会执行该操作吗?同时,我可以让容器内的一个或多个图像执行动画。

我希望这很清楚,并且我已经正确解释了我想做的事情。

最佳答案

不确定容器,
但我有另一种方法,

你为什么不制作一个自定义 View 并将所有图像放入其中,并且可以在该 View 上执行所有操作,

我发布了一些重要的方法,让我知道它是否适合你,我可能会分享更多细节

 -(void)refreshSession{
        // check all the added view, if needs to be displayed, then displayed them. 
        int visibleViews = [self getVisibleViews];

        if(visibleViews ==  0 ){
            // if no more views to be displayed, then then let it not be visible, 
            [[self window] orderOut:self];

            // do it will not be visible to anyone 
            return;
        }

        [self resize:visibleViews];


        int viewsPerSide = [self getViewsPerRow];//ceil(sqrt(count)); 

        int count = [pViewArray count];

        int viewIndex=0;
        NSInteger index = 0;
        NSPoint curPoint = NSZeroPoint;

        // Starting at the bottom left corner
        // we should check all visible views 
        for ( int i = 0; i < count ; i++ ) {

            // it will give only the view that needs to be shown
            NSView *subview = [self getViewAtIndex:i];//(NSView *)[pViewArray objectAtIndex:i];

            // is this visible 
            if(![self isViewVisibleAtIndex:i])
                continue;

            // is view visible 


            // if we have view to display then lets display it. 
            if(subview){
                //[[[self window] contentView]setBackgroundColor:[NSColor blackColor]];
                [[[self window]contentView] addSubview:subview ];
                [self checkMask:viewIndex view:subview];
                viewIndex++;

                // let all the frame have same rect, regardless what are those 
                NSRect frame = NSMakeRect(curPoint.x, curPoint.y, BOXWIDTH, BOXHEIGHT);
                // add them into the subview 
                NSRect newFrame = [self integralRect:frame];
                [subview setFrame:newFrame];
                [[subview animator] setFrame:[self integralRect:frame]];

                [self setSubViewMask:subview ContentView:[[self window]contentView]];

                // Now set the point 
                curPoint.x += BOXWIDTH + SEPARATION;                        // Stack them horizontally
                if ((++index) % viewsPerSide == 0) {                        // And if we have enough on this row, move up to the next
                    curPoint.x = 0;                
                    curPoint.y += BOXHEIGHT + SEPARATION;

                }
            }
        }
        NSArray *pSubViewsArray = [[[self window]contentView]subviews];
        int arrayCount = [pSubViewsArray count];

        debugLog<<"Array Count"<<arrayCount<<endl;

    }

关于iphone - 将多个 UIImages 插入到 "container",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10832578/

相关文章:

iphone - NSArray 中索引处的对象

ios - 图像 Assets 目录和 iOS 设备系列

iphone - 在 IOS 中通过 HTTP 流式传输视频

ios - TableView在View中覆盖整个屏幕

iphone - 以编程方式设置 iphone 模拟器位置

ios - 如何通过延迟 iOS 上的 block 调用来避免保留周期

iOS 什么用于排序列表?

objective-c - 在我的可编写脚本的应用程序中为 "make new"提供我自己的对象

ios - 获取请求返回 {(//value )} 而不仅仅是值

ios - 当应用程序在前台使用传入的 OneSignal 推送通知时,如何防止警报?