How to set the border of UITextView to same as border color of UITextField

前端 未结 8 2035
遇见更好的自我
遇见更好的自我 2020-12-24 10:37

By default UITextField has a light gray color as its border color. I want to set my UITextView to have the same border color as the UITextField.

I tried:

<         


        
8条回答
  •  执念已碎
    2020-12-24 11:09

    For generic solution through out the project. You can extern UIView class and add these methods to it.

    -(void)setBorderColor:(UIColor *)borderColor{
        self.layer.borderColor = (borderColor).CGColor;
    }
    -(UIColor*)borderColor{
        return [UIColor colorWithCGColor: self.layer.borderColor];
    }
    
    //Getter and setter for border width
    -(void)setBorderWidth:(NSInteger)borderWidth{
        self.layer.borderWidth = borderWidth;
    }
    -(NSInteger)borderWidth{
        return  (NSInteger)roundf((self.layer.borderWidth));
    }
    

    Its an extension to UIView. Just add these UIView+Designable.h/m files in your project and you can see the multiple more options in attribute inspector.

提交回复
热议问题