2012-01-18 56 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