public static MakeRoundedRectPath ( CGRect rect, float radius ) : CGPath | ||
rect | CGRect |
/// The |
radius | float |
/// The |
리턴 | CGPath |
public static void FillRoundedRect(CGContext ctx, CGRect rect, float radius) { var p = GraphicsUtil.MakeRoundedRectPath(rect, radius); ctx.AddPath(p); ctx.FillPath(); }
public override void Draw(CGRect rect) { var context = UIGraphics.GetCurrentContext(); var bounds = Bounds; UIColor background = Enabled ? pressed ? HighlightedColor : NormalColor : DisabledColor; nfloat alpha = 1; CGPath container = GraphicsUtil.MakeRoundedRectPath(bounds, 14); context.AddPath(container); context.Clip(); using (var cs = CGColorSpace.CreateDeviceRGB()) { var topCenter = new CGPoint(bounds.GetMidX(), 0); var midCenter = new CGPoint(bounds.GetMidX(), bounds.GetMidY()); var bottomCenter = new CGPoint(bounds.GetMidX(), bounds.GetMaxY()); using ( var gradient = new CGGradient(cs, new[] { 0.23f, 0.23f, 0.23f, alpha, 0.47f, 0.47f, 0.47f, alpha }, new nfloat[] { 0, 1 })) { context.DrawLinearGradient(gradient, topCenter, bottomCenter, 0); } container = GraphicsUtil.MakeRoundedRectPath(bounds.Inset(1, 1), 13); context.AddPath(container); context.Clip(); using ( var gradient = new CGGradient(cs, new[] { 0.05f, 0.05f, 0.05f, alpha, 0.15f, 0.15f, 0.15f, alpha }, new nfloat[] { 0, 1 })) { context.DrawLinearGradient(gradient, topCenter, bottomCenter, 0); } var nb = bounds.Inset(4, 4); container = GraphicsUtil.MakeRoundedRectPath(nb, 10); context.AddPath(container); context.Clip(); background.SetFill(); context.FillRect(nb); using (var gradient = new CGGradient(cs, new nfloat[] { 1, 1, 1, .35f, 1, 1, 1, 0.06f }, new nfloat[] { 0, 1 })) { context.DrawLinearGradient(gradient, topCenter, midCenter, 0); } context.SetLineWidth(2); context.AddPath(container); context.ReplacePathWithStrokedPath(); context.Clip(); using ( var gradient = new CGGradient(cs, new nfloat[] { 1, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f }, new nfloat[] { 0, 1 }) ) { context.DrawLinearGradient(gradient, topCenter, bottomCenter, 0); } } }