예제 #1
0
        public static void SetBarButtonItemAppearance(UIBarButtonItem.UIBarButtonItemAppearance appearance, UIColor color, UIColor highlightedColor, UIColor textColor, float cornerRadius, float borderWidth)
        {
            UIImage backButtonPortraitImage = FlatUI.BackButtonImage(color,
                                                                     UIBarMetrics.Default,
                                                                     cornerRadius,
                                                                     color.Darken(2),
                                                                     borderWidth);
            UIImage highlightedBackButtonPortraitImage = FlatUI.BackButtonImage(highlightedColor,
                                                                                UIBarMetrics.Default,
                                                                                cornerRadius,
                                                                                highlightedColor.Darken(2),
                                                                                borderWidth);
            UIImage backButtonLandscapeImage = FlatUI.BackButtonImage(color,
                                                                      UIBarMetrics.LandscapePhone,
                                                                      cornerRadius,
                                                                      color.Darken(2),
                                                                      borderWidth);
            UIImage highlightedBackButtonLandscapeImage = FlatUI.BackButtonImage(highlightedColor,
                                                                                 UIBarMetrics.LandscapePhone,
                                                                                 cornerRadius,
                                                                                 highlightedColor.Darken(2),
                                                                                 borderWidth);

            appearance.SetBackButtonBackgroundImage(backButtonPortraitImage, UIControlState.Normal, UIBarMetrics.Default);
            appearance.SetBackButtonBackgroundImage(backButtonLandscapeImage, UIControlState.Normal, UIBarMetrics.LandscapePhone);
            appearance.SetBackButtonBackgroundImage(highlightedBackButtonPortraitImage, UIControlState.Highlighted, UIBarMetrics.Default);
            appearance.SetBackButtonBackgroundImage(highlightedBackButtonLandscapeImage, UIControlState.Highlighted, UIBarMetrics.LandscapePhone);

            appearance.SetBackButtonTitlePositionAdjustment(new UIOffset(1f, 1f), UIBarMetrics.Default);
            appearance.SetBackButtonTitlePositionAdjustment(new UIOffset(1f, 1f), UIBarMetrics.LandscapePhone);

            UIImage buttonImageNormal = FlatUI.Image(color, cornerRadius, color.Darken(2), borderWidth);
            UIImage buttonImageHighlighted = FlatUI.Image(highlightedColor, cornerRadius, highlightedColor.Darken(2), borderWidth);

            appearance.SetBackgroundImage(buttonImageNormal, UIControlState.Normal, UIBarMetrics.Default);
            appearance.SetBackgroundImage(buttonImageHighlighted, UIControlState.Highlighted, UIBarMetrics.Default);

            UITextAttributes titleTextAttributes = appearance.GetTitleTextAttributes(UIControlState.Normal);
            if (titleTextAttributes == null)
                titleTextAttributes = new UITextAttributes();
            titleTextAttributes.TextShadowColor = UIColor.Clear;
            titleTextAttributes.TextShadowOffset = new UIOffset(0, 0);
            titleTextAttributes.TextColor = textColor;
            titleTextAttributes.Font = FlatUI.FontOfSize(0);
            appearance.SetTitleTextAttributes(titleTextAttributes, UIControlState.Normal);
            appearance.SetTitleTextAttributes(titleTextAttributes, UIControlState.Highlighted);
        }
예제 #2
0
        //UIEdgeInsets DefaultEdgeInsets, NormalEdgeInsets, HighlightedEdgeInsets;

        public FUIButton(RectangleF frame, UIColor buttonColor, UIColor highlightedColor, float borderWidth = 1f, float cornerRadius = 5f)
            : this(frame, buttonColor, highlightedColor, buttonColor.Darken(2), highlightedColor.Darken(2), borderWidth, cornerRadius)
        {
        }