This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // UI View extension methods | |
| public static class UIViewExtensions | |
| { | |
| // Add these two static readonly variables | |
| private static readonly string COLOR_BORDERS_EXT = "color-borders-ext"; | |
| private static readonly BorderDirection[] ALL_BORDERS = new BorderDirection[] { BorderDirection.Bottom, BorderDirection.Left, BorderDirection.Right, BorderDirection.Top }; | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Method for coloring UIView borders | |
| public static void ColorBorders(this UIView view, CGColor color, nfloat width, BorderDirection directions) | |
| { | |
| // Loop through the four possible borders | |
| foreach(var border in ALL_BORDERS) | |
| { | |
| // Checks that the current border should be colored | |
| if((border & direction) == border) | |
| { | |
| //TODO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using CoreGraphics; | |
| using System; | |
| using UIKit; | |
| namespace TextFieldValidation_Medium | |
| { | |
| // UI View extension methods | |
| public static class UIViewExtensions | |
| { | |
| // Method for coloring UIView borders |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Checks that the current border should be colored | |
| if((border & directions) == border) | |
| { | |
| // Sublayer name | |
| var name = $"{COLOR_BORDERS_EXT}.{border.ToString()}"; | |
| // Attempt to find sublayer by name | |
| var sublayer = view.Layer.Sublayers?.FirstOrDefault(layer => layer.Name != null && | |
| layer.Name.Equals(name)); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| } | |
| } // End foreach loop on ALL_BORDERS | |
| // Gets the border frame based on the direction provided | |
| CGRect GetBorderFrame(BorderDirection border) | |
| { | |
| switch(border) | |
| { | |
| case BorderDirection.Top: | |
| return new CGRect(0, 0, view.Frame.Width, width); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| sublayer.Frame = GetBorderFrame(border); // Border Frame | |
| sublayer.Name = name; // Name the sublayer | |
| sublayer.BorderWidth = width; // Set the border width | |
| sublayer.BorderColor = color; // Set the border color | |
| } | |
| } // End foreach loop on ALL_BORDERS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public override void ViewDidLoad() | |
| { | |
| base.ViewDidLayoutSubviews(); | |
| NameTextField.ColorBorders(NameTextField.TextColor.CGColor, 4, BorderDirection.Bottom); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using CoreGraphics; | |
| using System; | |
| using UIKit; | |
| namespace TextFieldValidation_Medium | |
| { | |
| public class BorderedTextField | |
| { | |
| public UITextField TextField { get; set; } | |
| public CGColor BorderColor { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NameTextField.ColorBorders(NameTextField.TextColor.CGColor, 4, BorderDirection.Bottom); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var borderedField = new BorderedTextField(NameTextField, NameTextField.TextColor.CGColor, BorderDirection.Bottom, 4); |
OlderNewer