English 中文(简体)
射电压倒了图像,暴露了基底。 (A-la j Query.slide(A))
原标题:iOS slide up an image over an image, revealing the underneath one. (A-la jQuery.slide())

页: 1

我有两种相同的形象,一种有色,一种有黑白。 我希望B&W“滑坡”能够揭示它下的情况。

I tried setting the height and the frame, but couldn t get it to work like I want it to.

举例来说,如果二氧化二氮相互暴露,则二者结合使用,但不得移动:

“enterography

任何想法?

最佳回答

在这里,科索沃是一种使用灰色观点掩盖的方法。 我实际上用蓝色言和灰色言对此进行了测试。 在灰色层穿戴面罩,使灰层可见。 现在,在灰色层外穿透面,使灰层消失而不移,蓝色显示灰尘消失。

如果你想对此进行试验,就在XCode建立一个单一观点的空洞项目,并将这一守则置于GeoDidLoad。 这是我如何测试的。

self.view.backgroundColor = [UIColor whiteColor];

UIView* blueView = [[[UIView alloc] init] autorelease];
blueView.backgroundColor = [UIColor blueColor];
blueView.frame = CGRectMake(50,50,100,100);

UIView* grayView = [[[UIView alloc] init] autorelease];
grayView.backgroundColor = [UIColor grayColor];
grayView.frame = CGRectMake(50,50,100,100);

[self.view addSubview:blueView];
[self.view addSubview:grayView];    // gray covers the blue

// Create a mask to allow the grey view to be visible and cover up the blue view
CALayer* mask = [CALayer layer];
mask.contentsScale   = grayView.layer.contentsScale;  // handle retina scaling
mask.frame           = grayView.layer.bounds;
mask.backgroundColor = [UIColor blackColor].CGColor;
grayView.layer.mask = mask;

// Animate the position of the mask off the grey view, as the grey becomes unmasked,
// that part of the grey "dissappears" and is no longer covering the blue underneath
CABasicAnimation* a = [CABasicAnimation animationWithKeyPath:@"position"];
a.duration  = 4;
a.fromValue = [NSValue valueWithCGPoint:mask.position];
CGPoint newPosition = mask.position;
newPosition.y += mask.bounds.size.height;
a.toValue   = [NSValue valueWithCGPoint:newPosition];
a.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[mask addAnimation:a forKey:@"colorize"];   // animate presentation

mask.position = newPosition;        // update actual position

Don t forget this line at the top with the #imports:

#import <QuartzCore/QuartzCore.h>
问题回答

一种方式是打碎“F”号,使“B&”在彩色形象上的形象被“B&”完全覆盖(隐藏的)。

[self.view insertSubview:bwImage aboveSubview:colorImage];

只见B&W观点。 现在搁置一页。 ToBounds on the B&W view:

bwImage.clipsToBounds = YES;

最后, b顶的高度接近尾声,使其高度缩小到0,击退B&W形象和显示其背后的肤色形象。 与此类似:

[UIView animateWithDuration:1.0 animations:^{
    CGRect b = bwImage.bounds;
    b.size.height = 0;
    bwImage.bounds = b;
}];

我没有这样做,但希望你们能够这样做。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签