简体   繁体   中英

Draw Rect Monotouch PaintCode

I'm trying to make a better UI for my application but I'm stuck in this. My designing skills aren't good so I'm trying PaintCode. I want to make a Login Screen with this shadow beneath the group of username and password.

阴影UiView

I can't use a UIView so I made the same but in PaintCode using a Rect.

var context = UIGraphics.GetCurrentContext();
//// Shadow Declarations
var shadow = UIColor.DarkGray.ColorWithAlpha(0.71f).CGColor;
var shadowOffset = new SizeF(6.1f, 4.1f);
var shadowBlurRadius = 5.0f;

   //// Rectangle Drawing
 UIBezierPath rectanglePath = new UIBezierPath();
 rectanglePath.MoveTo(new PointF(18.0f, 239.0f));
 rectanglePath.AddLineTo(new PointF(383.0f, 239.0f));
 rectanglePath.AddLineTo(new PointF(383.0f, 13.0f));
 rectanglePath.AddLineTo(new PointF(18.0f, 13.0f));
 rectanglePath.AddLineTo(new PointF(18.0f, 239.0f));
 rectanglePath.ClosePath();
 context.SaveState();
 context.SetShadowWithColor(shadowOffset, shadowBlurRadius, shadow);
 UIColor.White.SetFill();
 rectanglePath.Fill();
 context.RestoreState();

Now I don't know what to do with that code. In the tutorials and documentation they usually make a UIView so they just subclass a UIView and add it in Interface Builder, that way you can always know exactly where the object is going to end in your final app. I don't know what to subclass and how to make the rect I draw beneath my username and password boxes.

Create a custom class inheriting from UIView, then override Draw function and put your custom code there.

[Register("DrawView")]
public class DrawView : UIView
{
    public override void Draw(System.Drawing.RectangleF rect)
    {

In the above sample the Register attribute is necessary if you want to use your control from XCode designer (or Xamarin Storyboard designer).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM