How to change contentview height?


    class FriendCell : BaseCell<string>
    {
        protected internal FriendCell(IntPtr handle) : base(handle)
        {
            
        }

        public override void Init(IList<string> source, NSIndexPath path)
        {
            UILabel label1 = new UILabel
            {
                Text = "test",
                TextAlignment=UITextAlignment.Center,
                BackgroundColor = UIColor.White,
            };
            label1.SizeToFit();
            UILabel label2 = new UILabel
            {
                Text = "test2",
                TextAlignment = UITextAlignment.Center,
                BackgroundColor = UIColor.White,
            };
            UILabel label3= new UILabel
            {
                Text = "test3",
                TextAlignment = UITextAlignment.Center,
                BackgroundColor = UIColor.White,
            };
            SfPopupLayout popupLayout = new SfPopupLayout();
            popupLayout.PopupView.PopupStyle.OverlayOpacity = 0;
            popupLayout.PopupView.ShowHeader = false;
            popupLayout.PopupView.ShowFooter = false;
            popupLayout.PopupView.ContentView = new UIStackView(new UIView[] { label1, label2, label3 })
            {
                Frame=new CGRect(0,0,100,100),
                Axis = UILayoutConstraintAxis.Vertical,
                Distribution = UIStackViewDistribution.FillEqually,
                Alignment=UIStackViewAlignment.Top,
                BackgroundColor=UIColor.LightGray,
            };
            //popupLayout.PopupView.ContentView.Bounds = new CGRect(0, 20, 100, 100);
            //popupLayout.PopupView.ContentView.BackgroundColor = UIColor.LightGray;            

            UILabel labelName = new UILabel
            {
                Text = source[path.Row],
                Font = UIFont.SystemFontOfSize(20),
            };
            UILabel labelMsg = new UILabel
            {
                Lines = 1,
                Text = "msg",
                LineBreakMode=UILineBreakMode.TailTruncation,
                Font = UIFont.SystemFontOfSize(16),
            };
            UIButton labelMore = new UIButton(UIButtonType.System)
            {
                Font = UIFont.FromName("FontAwesome", 24),
                UserInteractionEnabled=true,

            };
            labelMore.SetTitle("\uF142", UIControlState.Normal);
            labelMore.SetContentHuggingPriority(260, UILayoutConstraintAxis.Horizontal);
            labelMore.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            {
                //popupLayout.ShowRelativeToView(labelMore,RelativePosition.AlignTopLeft,0,0);
                popupLayout.Show();
            }));
            UIStackView stack2 = new UIStackView(new UIView[] { labelName, labelMsg })
            {
                Axis = UILayoutConstraintAxis.Vertical,
                Distribution=UIStackViewDistribution.Fill,
            };
            UIStackView stack1 = new UIStackView(new UIView[] { stack2, labelMore })
            {
                TranslatesAutoresizingMaskIntoConstraints=false,
                Axis = UILayoutConstraintAxis.Horizontal,
                Distribution = UIStackViewDistribution.Fill,
            };

            ContentView.AddSubview(stack1);
            stack1.TopAnchor.ConstraintEqualTo(ContentView.TopAnchor,4).Active = true;
            stack1.LeadingAnchor.ConstraintEqualTo(ContentView.LeadingAnchor,8).Active = true;
            stack1.TrailingAnchor.ConstraintEqualTo(ContentView.TrailingAnchor,-16).Active = true;
            stack1.BottomAnchor.ConstraintEqualTo(ContentView.BottomAnchor,-8).Active = true;            
            
        }
    }

FriendCell is UITableViewCell.
I cant change contentview height.

How to change contentview height?

Attachment: screenshot_cfdc243b.zip

1 Reply 1 reply marked as answer

PK Pradeep Kumar Balakrishnan Syncfusion Team February 24, 2021 11:10 AM UTC

Hi Kss, 
 
Thank you for using Syncfusion controls. 
 
We have checked your requirement “How to change the SfPopupLayout.PopupView.ContentView height in Xamarin IOS” and your requirement can be achieved by defining SfPopupLayout.PoupView.Frame. Please refer to the following code snippet for the same. 
 
Code Snippet:  
public override void ViewDidLayoutSubviews() 
{ 
    base.ViewDidLayoutSubviews(); 
    popupLayout.Frame = new CGRect(0, 20, this.View.Frame.Width, this.View.Frame.Height - 20); 
    popupLayout.PopupView.Frame = new CGRect((popupLayout.Frame.Width - 75) / 2, (popupLayout.Frame.Height - 100) / 2, 75, 100); 
} 
We have also attached sample for your reference in the following link. 
 
Let us know if you need any further assistance on this. 
 
Regards, 
Pradeep Kumar B 


Marked as answer
Loader.
Up arrow icon