2012-03-22 3 views
0

私はこのコードを持っていますが、ビューに何も追加していません。何が間違っているのか理解できますか? 私はイメージにファイラーを適用しますが、これが完了したときには後になりますが、フィルターを追加する場合はこれが間違った方法であるかどうかを教えてください。objective-c - コアグラフィックスを使用したUIImageを作成

UIGraphicsPushContext(context); 

CALayer *layer = [CALayer layer]; 
CGColorRef bgColor = [UIColor colorWithHue:0.6 saturation:1.0 brightness:1.0 alpha:1.0].CGColor; 
layer.frame = CGRectMake(0, 0, 200, 200); 

CGContextSetFillColorWithColor(context, bgColor); 
CGContextFillRect(context, layer.bounds); 

CGContextSaveGState(context); 
CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(NULL); 
CGContextSetFillColorSpace(context, patternSpace); 
CGColorSpaceRelease(patternSpace); 

CGContextFillRect(context, layer.bounds); 
CGContextRestoreGState(context);  
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 

UIGraphicsEndImageContext(); 

UIImageView *borrar = [[UIImageView alloc]initWithImage:image]; 

[self.view addSubview:borrar]; 

答えて

0

イメージのコンテキストを決して開けません。 UIGraphicsBeginImageContextWithOptionsを使用してください。

関連する問題