2014-06-06 4 views
1

내 응용 프로그램을위한 더 나은 UI를 만들려고 노력하고 있지만 여기에 갇혀 있습니다. 내 설계 기술이 좋지 않아서 PaintCode를 시도하고있다. 사용자 이름과 암호 그룹 아래에이 그림자가있는 로그인 화면을 만들고 싶습니다. 내가 UIView의를 사용할 수 없습니다Draw Rect Monotouch PaintCode

Shadowed UiView

그래서 같은 있지만 PaintCode에 사각형을 사용했다.

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(); 

이제이 코드를 어떻게 처리해야할지 모르겠습니다. 튜토리얼과 문서에서는 대개 UIView를 작성하여 UIView를 서브 클래스 화하고 인터페이스 빌더에 추가하므로 최종 애플 리케이션에서 오브젝트가 끝나는 곳을 정확히 알 수 있습니다. 서브 클래 싱 할 대상과 사용자 이름과 암호 상자 아래에 직사각형을 그리는 방법을 모르겠습니다.

답변

3

UIView에서 상속하는 사용자 지정 클래스를 만든 다음 Draw 함수를 재정 의하여 사용자 지정 코드를 추가하십시오.

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

위 예제에서 XCode 디자이너 (또는 Xamarin Storyboard 디자이너)에서 컨트롤을 사용하려면 Register 특성이 필요합니다.