2012-01-18 62 views
0

我想显示在整个屏幕上的iPhone应用的图像,但具有半曲线的形状。 图像应该从角落开始触摸,结束于触摸另一个角落。我没有一个想法让这个任何人都可以帮助我。 该图像表是半弯曲但图像应显示上半弯曲形状要显示的图像上的视图,但在semicurve形状

This image table is semi curved but image should be displayed on semi curved shape

+0

你的意思是你希望你的UIView为半弯曲?为什么不使用alpha? – 2012-01-18 06:10:35

+0

通过使用阿尔法它不是看起来半曲线.. – shivangi 2012-01-18 06:24:17

回答

0

改变图像是curvical或与图像播放,可以实现使用的CALayer。每个imageView都有一个图层。用它来显示效果。你想你的表图像的影响可以通过这个代码来达到的: -

-(void) viewDidLoad{ 

    [self paperCurlShadowImage]; 
} 

-(void) paperCurlShadowImage{ 

     imgView = [[UIImageView alloc] initWithImage:image]; 
     imgView.frame=CGRectMake(0, 0, image.size.width, image.size.height); 


     [self.view addSubview:imgView]; 

     imgView.layer.shadowColor = [UIColor blackColor].CGColor; 
     imgView.layer.shadowOpacity = 0.7f; 
     imgView.layer.shadowOffset = CGSizeMake(10.0f, 10.0f); 
     imgView.layer.shadowRadius = 2.0f; 
     imgView.layer.masksToBounds = NO; 


     imgView.layer.shadowPath = [self renderPaperCurl:imgView]; 
     [imgView release]; 

}

- (CGPathRef)renderPaperCurl:(UIView*)imgView1 { 
    CGSize size = imgView1.bounds.size; 
    CGFloat curlFactor = 15.0f; 
    CGFloat shadowDepth = 5.0f; 

    UIBezierPath *path = [UIBezierPath bezierPath]; 
    [path moveToPoint:CGPointMake(0.0f, 0.0f)]; 
    [path addLineToPoint:CGPointMake(size.width, 0.0f)]; 
    [path addLineToPoint:CGPointMake(size.width, size.height + shadowDepth)]; 
    [path addCurveToPoint:CGPointMake(0.0f, size.height + shadowDepth) 
      controlPoint1:CGPointMake(size.width - curlFactor, size.height + shadowDepth - curlFactor) 
      controlPoint2:CGPointMake(curlFactor, size.height + shadowDepth - curlFactor)]; 

    return path.CGPath; 
} 
+0

imgView.layer.shadowColor = [的UIColor blackColor] .CGColor; \t imgView.layer.shadowOpacity = 0.7f; \t imgView.layer.shadowOffset = CGSizeMake(10.0f,10.0f); \t imgView.layer.shadowRadius = 2.0F; \t imgView.layer.masksToBounds = NO; \t \t \t imgView.layer.shadowPath = [self renderPaperCurl:imgView]; – shivangi 2012-01-18 08:12:03

+0

这些线路都出现的“访问属性的未知则shadowColor组件错误。同样用不同的名字都行。请帮我 – shivangi 2012-01-18 08:14:04

+0

你已导入quartzCore,CoreGraphics中无论是在你的项目的框架? – 2012-01-18 08:18:13