コード例 #1
0
        public static UIImage SetBackgroundSettings(this IStyleSheet styleSheet, Control control)
        {
            IStyleSheetHelper style = styleSheet.Helper;

            UIImage image = styleSheet.GetBackgroundImage(control);

            if (image != null)
            {
                return(image);
            }

            control.View.BackgroundColor = style.BackgroundColor(control).ToColorOrClear();
            if (style.HasBorder(control))
            {
                control.View.ClipsToBounds      = true;
                control.View.Layer.BorderWidth  = style.BorderWidth(control);
                control.View.Layer.BorderColor  = style.BorderColor(control).ToColorOrClear().CGColor;
                control.View.Layer.CornerRadius = style.BorderRadius(control);
            }
            return(null);
        }
コード例 #2
0
        protected override IBound Apply(IStyleSheet stylesheet, IBound styleBound, IBound maxBound)
        {
            base.Apply(stylesheet, styleBound, maxBound);

            IStyleSheetHelper style = stylesheet.Helper;

            // background image
            _backgroundImage = FromSource() ?? stylesheet.GetBackgroundImage(this);

            if (_backgroundImage != null)
            {
                _view.Image = _backgroundImage;

                // selected-color
                UIColor selectedColor = style.SelectedColor(this).ToNullableColor();
                if (selectedColor != null)
                {
                    _selectedImage = GetFilteredImage(_backgroundImage, selectedColor);
                }
            }

            // size to content by background
            return(GetBoundByImage(styleBound, maxBound, _backgroundImage));
        }