Exemplo n.º 1
0
        private void UpdateLayout()
        {
            var rect = new NSString(NameLabel.LabelText).GetBoundingRect(
                new CGSize(Frame.Width, 1000),
                NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin,
                new UIStringAttributes()
            {
                Font = UIFont.SystemFontOfSize(14)
            },
                null);

            if (rect.Height > 20)
            {
                CategoryLabel.Frame = new CGRect(0, Frame.Width + 38, Frame.Width, 20);
                PriceLabel.Frame    = new CGRect(0, Frame.Width + 56, Frame.Width, 20);
            }
            else
            {
                CategoryLabel.Frame = new CGRect(0, Frame.Width + 22, Frame.Width, 20);
                PriceLabel.Frame    = new CGRect(0, Frame.Width + 40, Frame.Width, 20);
            }

            NameLabel.Frame = new CGRect(0, Frame.Width + 5, Frame.Width, 40);
            NameLabel.SizeToFit();
        }