Search code examples
iosuitableviewuiviewios7xamarin.ios

Layer boarder not showing at top and right edge of view and UITableView


I use below codes in order to adding borders to UIView and also border to an UITableView.

for UIView:

RectangleF _frame = new RectangleF (0, 0, this.Frame.Width , 56);
                DescriptionView = new UIView (_frame);
                DescriptionView.BackgroundColor = UIColor.White  ;
                DescriptionView.Layer.BorderColor = new CGColor (0, 0, 0, 1.0f);
                DescriptionView.Layer.BorderWidth = 0.5f;

For UITable:

RectangleF _frame = new RectangleF (0, DescriptionView.Frame.Height + 10,
                this.Frame.Width , this.Frame.Height - (DescriptionView.Frame.Height + 10));
            InstructionTable = new UITableView (_frame);
            InstructionTable.Layer.BorderColor = new CGColor (0, 0, 0, 1.0f);
            InstructionTable.Layer.BorderWidth = 0.5f;

for iPhone 3.5 inch and iPhone 4inch it works fine but for iPad the border is not showing on right of the view and also on top and right of the table. See below screen shot:

enter image description here


Solution

  • Instead of:

    DescriptionView.Layer.BorderWidth = 0.5f;
    

    I used grater width:

    DescriptionView.Layer.BorderWidth = 1f;
    

    and it fixed my problem