Last active
August 29, 2015 14:00
-
-
Save victorchee/11136064 to your computer and use it in GitHub Desktop.
iOS放射渐进视图
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGContextRef context = UIGraphicsGetCurrentContext(); | |
size_t num_locations = 2; | |
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); | |
CGFloat components[8] = {1,1,1,1, // 中心颜色(r, g, b, alpha) | |
.2,.2,.2,1 // 边缘颜色}; | |
CGFloat locations[2] = {0,1}; | |
CGGradientRef gradient = CGGradientCreateWithColorComponents(rgb, components, locations, num_locations); | |
CGColorSpaceRelease(rgb); | |
CGRect bounds = self.bounds; | |
CGPoint center = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds)); // 中心发散渐进 | |
CGContextDrawRadialGradient(context, gradient, center, 0, center, bounds.size.width, kCGGradientDrawsAfterEndLocation); | |
CGGradientRelease(gradient); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment