0
グラデーションが入ったボックスを描く必要があります。私はUIViewを使用して、-drawRectメソッドを上書きしています。ここでiPhone:描画勾配の幅を制御できないのですか?
は私のコード(簡体字)である:
CGContextRef c = UIGraphicsGetCurrentContext();
CGFloat components[8] = {158.0/255.0,36.0/255.0,134.0/255.0,1.0,115.0/255.0,26.0/255.0,93.0/255.0,1.0};
CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB();
CGFloat locations[2] = {0.0,1.0};
CGGradientRef glossGradient = CGGradientCreateWithColorComponents(rgbColorspace, components, locations, 2);
CGPoint topCenter = CGPointMake(10, 0);
CGPoint bottomCenter = CGPointMake(10, 10);
CGContextDrawLinearGradient(c, glossGradient, topCenter, bottomCenter, 0);
勾配が現状で埋めるビューの幅全体を埋めます!描画しているグラデーションの塗りつぶし枠の幅を制御するにはどうすればよいですか?