Here is the code snippet for that to be written inside - (void)drawRect:(CGRect)rect of UIView
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextRef ctx = UIGraphicsGetCurrentContext();
//Draw the gray Gradient
CGFloat BGLocations[2] = { 0.0, 1.0 };
CGFloat BgComponents[8] = { 0.25, 0.25, 0.25 , 1.0, // Start color
0.11, 0.11, 0.11, 1.0 }; // Mid color and End color
CGColorSpaceRef BgRGBColorspace = CGColorSpaceCreateDeviceRGB();
CGGradientRef bgRadialGradient = CGGradientCreateWithColorComponents(BgRGBColorspace, BgComponents, BGLocations, 2);
CGPoint startBg = CGPointMake(250, 250);
CGFloat endRadius= 250;
CGContextDrawRadialGradient(ctx, bgRadialGradient, startBg, 0, startBg, endRadius, kCGGradientDrawsAfterEndLocation);
CGColorSpaceRelease(BgRGBColorspace);
CGGradientRelease(bgRadialGradient);
Screenshot of the output |
Thông tin thật hưu ích, cảm ơn bạn đã chia sẻ.
ReplyDeleteXem tại Page : Giá đá thạch anh
Kiến thức của Bạn cũng cần thiết, cám ơn bạn đã chia sẻ.
ReplyDeletePage hữu ích : Giá thạch anh vụn
Bài post của Admin rất hay, cám ơn bạn đã chia sẻ.
ReplyDeleteXem tại website : Gia công đá thạch anh
i have created a new file to have this code in cgrect but what if i want to change the end radius. How can i override this function
ReplyDeletei have created a new file to have this code in cgrect but what if i want to change the end radius. How can i override this function
ReplyDelete