Esempio n. 1
0
        private void CreateLayout()
        {
            //ContentView.Transform = CGAffineTransform.MakeScale(1, -1);
            _stack = new UIStackView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Distribution = UIStackViewDistribution.EqualSpacing,
                Spacing      = 5,
                Axis         = UILayoutConstraintAxis.Vertical,
            };
            _title = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font            = UIFont.SystemFontOfSize(15f, UIFontWeight.Bold),
                TextColor       = UIColor.Black,
                TextAlignment   = UITextAlignment.Left,
                BackgroundColor = UIColor.Clear,
                Lines           = 1,
            };
            _content = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font            = UIFont.SystemFontOfSize(15f, UIFontWeight.Regular),
                TextColor       = UIColor.Black,
                TextAlignment   = UITextAlignment.Left,
                BackgroundColor = UIColor.Clear,
                Lines           = 0,
            };
            _contentSmall = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font            = UIFont.SystemFontOfSize(15f, UIFontWeight.Regular),
                TextColor       = UIColor.Black,
                TextAlignment   = UITextAlignment.Left,
                BackgroundColor = UIColor.Clear,
                Lines           = 1
            };
            _createdAt = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font            = UIFont.SystemFontOfSize(11f, UIFontWeight.Regular),
                TextColor       = UIColor.Gray,
                TextAlignment   = UITextAlignment.Left,
                BackgroundColor = UIColor.Clear,
                Lines           = 1
            };
            _button = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            //_button.SetTitle("Показать еще...", UIControlState.Normal);
            _button.SetTitleColor(UIColor.Black, UIControlState.Normal);

            ContentView.AddSubviews(_stack);

            _stack.AddArrangedSubview(_title);
            _stack.AddArrangedSubview(_createdAt);
            _stack.AddArrangedSubview(_content);
            _stack.AddArrangedSubview(_contentSmall);
            _stack.AddArrangedSubview(_button);

            _stack.HeightEqualTo(ContentView, ContentView);
            _stack.WidthEqualTo(ContentView, ContentView);
            _stack.LeftEqualTo(ContentView, ContentView);
            _stack.RightEqualTo(ContentView, ContentView);
            _stack.TopEqualTo(ContentView, ContentView);
            _stack.BottomEqualTo(ContentView, ContentView);

            _title.WidthEqualTo(_stack, _stack, margin: -20);
            _title.LeftEqualTo(_stack, _stack, margin: 10);
            _title.RightEqualTo(_stack, _stack, margin: -10);

            _createdAt.WidthEqualTo(_stack, _stack, margin: -20);
            _createdAt.LeftEqualTo(_stack, _stack, margin: 10);
            _createdAt.RightEqualTo(_stack, _stack, margin: -10);

            _contentSmall.WidthEqualTo(_stack, _stack, margin: -20);
            _contentSmall.LeftEqualTo(_stack, _stack, margin: 10);
            _contentSmall.RightEqualTo(_stack, _stack, margin: -10);

            _content.WidthEqualTo(_stack, _stack, margin: -20);
            _content.LeftEqualTo(_stack, _stack, margin: 10);
            _content.RightEqualTo(_stack, _stack, margin: -10);
        }