Cannot insert a UIView under another.

JohnMcDonaghJohnMcDonagh GBMember ✭✭
edited October 2016 in Xamarin.iOS

I have a UIView (bookView) on which I have added a bunch of CALayers that draw text.

I am trying to highlight particular words by inserting a UIView (highlightView) with a yellow background color under the bookView.
However no matter what I do the yellow highlightView appears OVER the text of the CALayer

      //draw text in CALayer textLayer
  bookView.Layer.AddLayer(textLayer);
   var highlightView = new UIView(rectangle);
  highlightView.BackgroundColor = UIColor.Yellow;
    //bookView.InsertSubview(highlightView, 0); 
        //InsertSubviewBelow(highlightView, textView);
        AddSubview(highlightView);
        SendSubviewToBack(highlightView);

Setting the bookView.BackgroundColor to anything other than clear also seems to make the CALayer text disappear.
Changing the CALayer background color does the same thing.

If anyone can tell me how to fix this I will be very grateful.

John

Sign In or Register to comment.