mf textview similar to BR
This commit is contained in:
parent
8b4ab2c075
commit
1273321387
@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "SeparatorView.h"
|
||||
|
||||
@interface CustomTextView: UITextView
|
||||
|
||||
@ -25,7 +26,14 @@
|
||||
|
||||
@property (weak, nonatomic) id delegate;
|
||||
@property (weak, nonatomic) IBOutlet CustomTextView *textView;
|
||||
@property (assign, nonatomic) BOOL hideBorder;
|
||||
@property (strong, nonatomic) UIBezierPath *borderPath;
|
||||
@property (nonatomic, readwrite) BOOL errorShowing;
|
||||
@property (weak, nonatomic) SeparatorView *bottomLine;
|
||||
|
||||
|
||||
+(MFTextView *) MFTextViewWithPlaceholderString:(NSString *) placeholder delegate:(id) delegate;
|
||||
|
||||
- (void)makeBordersForTextView;
|
||||
|
||||
@end
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
#import "UIColor+MFConvenience.h"
|
||||
#import "MVMCoreUIUtility.h"
|
||||
#import "MVMCoreUIConstants.h"
|
||||
#import "MFStyler.h"
|
||||
|
||||
@import MVMCore.MVMCoreConstants;
|
||||
|
||||
@protocol CustomTextViewDelegate <UITextViewDelegate>
|
||||
@ -163,7 +165,55 @@
|
||||
view.textView.smartInsertDeleteType = UITextSmartInsertDeleteTypeNo;
|
||||
}
|
||||
[view didSetFont:view.textView.font];
|
||||
|
||||
// self.bottomLine = bottomLine;
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - bordered textview
|
||||
- (void)makeBordersForTextView {
|
||||
|
||||
SeparatorView *bottomLine = [SeparatorView separatorAddToView:self position:SeparatorPositionBot];
|
||||
self.placeHolderLabel.font = [MFStyler fontB3];
|
||||
[self.textView setFont:[MFStyler fontB2]];
|
||||
[self.textView setTextContainerInset:UIEdgeInsetsMake(PaddingTwo, PaddingTwo, PaddingTwo, PaddingOne)];
|
||||
self.errorShowing = false;
|
||||
}
|
||||
|
||||
- (void)addBezierPathForBorders {
|
||||
CGRect frame = self.frame;
|
||||
self.borderPath = [UIBezierPath bezierPath];
|
||||
[self.borderPath moveToPoint:CGPointMake(frame.origin.x, frame.origin.y + frame.size.height)];
|
||||
[self.borderPath addLineToPoint:CGPointMake(frame.origin.x, frame.origin.y)];
|
||||
[self.borderPath addLineToPoint:CGPointMake(frame.origin.x + frame.size.width, frame.origin.y)];
|
||||
[self.borderPath addLineToPoint:CGPointMake(frame.origin.x + frame.size.width, frame.origin.y + frame.size.height)];
|
||||
|
||||
self.borderPath.lineWidth = 1;
|
||||
|
||||
UIColor *strokeColor;
|
||||
if (self.errorShowing) {
|
||||
strokeColor = [UIColor mfPumpkinColor];
|
||||
self.bottomLine.backgroundColor = [UIColor mfPumpkinColor];
|
||||
} else {
|
||||
strokeColor = [UIColor mfSilver];
|
||||
self.bottomLine.backgroundColor = [UIColor mfSilver];
|
||||
}
|
||||
|
||||
[strokeColor setStroke];
|
||||
|
||||
[self.borderPath stroke];
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
[super drawRect:rect];
|
||||
[self.borderPath removeAllPoints];
|
||||
self.layer.cornerRadius = 0;
|
||||
self.hideBorder = false;
|
||||
if (!self.hideBorder) {
|
||||
[self addBezierPathForBorders];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user