【发布时间】:2011-12-29 05:35:56
【问题描述】:
我创建了一个自定义进度条,它继承了 UIView 并实现了 drawRect。我设法在整个视图上绘制了一个渐变。但是,我想绘制几个不同的渐变,每个渐变都在不同的位置。如何将CGContextDrawLinearGradient 限制为视图内的较小矩形?
glossGradient = CGGradientCreateWithColorComponents(rgbColorspace, components, locations, num_locations);
CGPoint topCenter = CGPointMake(start + (CGRectGetMidX(currentBounds)/currentBounds.size.width), 0.0f);`
CGPoint midCenter = CGPointMake(start + (CGRectGetMidX(currentBounds)/currentBounds.size.width), currentBounds.size.height);
CGContextDrawLinearGradient(currentContext, glossGradient, topCenter, midCenter, 0);
start = start + (values[i] / currentBounds.size.width);
CGGradientRelease(glossGradient);
}
【问题讨论】:
标签: objective-c ios graphics