fix: textView's placeholder position error bug .
This commit is contained in:
parent
d412d456bb
commit
6eb014eab3
@ -9,6 +9,7 @@ import {
|
||||
Color,
|
||||
input,
|
||||
text,
|
||||
log,
|
||||
} from "doric";
|
||||
import { preferenceView } from "./components/PreferenceView";
|
||||
import { title } from "./utils";
|
||||
|
@ -70,6 +70,28 @@ - (void)setText:(NSString *)text {
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
if (self.contentSize.height < self.height) {
|
||||
if ((self.gravity & DoricGravityTop) == DoricGravityTop) {
|
||||
self.contentInset = UIEdgeInsetsMake(
|
||||
0,
|
||||
self.contentInset.left,
|
||||
self.contentInset.bottom,
|
||||
self.contentInset.right);
|
||||
} else if ((self.gravity & DoricGravityBottom) == DoricGravityBottom) {
|
||||
self.contentInset = UIEdgeInsetsMake(
|
||||
self.height - self.contentSize.height,
|
||||
self.contentInset.left,
|
||||
self.contentInset.bottom,
|
||||
self.contentInset.right);
|
||||
} else {
|
||||
self.contentInset = UIEdgeInsetsMake(
|
||||
(self.height - self.contentSize.height) / 2,
|
||||
self.contentInset.left,
|
||||
self.contentInset.bottom,
|
||||
self.contentInset.right);
|
||||
}
|
||||
}
|
||||
|
||||
self.placeholderLabel.hidden = self.text.length > 0;
|
||||
if (!self.placeholderLabel.hidden) {
|
||||
CGFloat lineFragmentPadding = self.textContainer.lineFragmentPadding;
|
||||
@ -90,26 +112,8 @@ - (void)layoutSubviews {
|
||||
} else {
|
||||
self.placeholderLabel.centerY = (self.height - textContainerInset.top - textContainerInset.bottom) / 2 ;
|
||||
}
|
||||
}
|
||||
if (self.contentSize.height < self.height) {
|
||||
if ((self.gravity & DoricGravityTop) == DoricGravityTop) {
|
||||
self.contentInset = UIEdgeInsetsMake(
|
||||
0,
|
||||
self.contentInset.left,
|
||||
self.contentInset.bottom,
|
||||
self.contentInset.right);
|
||||
} else if ((self.gravity & DoricGravityBottom) == DoricGravityBottom) {
|
||||
self.contentInset = UIEdgeInsetsMake(
|
||||
self.height - self.contentSize.height,
|
||||
self.contentInset.left,
|
||||
self.contentInset.bottom,
|
||||
self.contentInset.right);
|
||||
} else {
|
||||
self.contentInset = UIEdgeInsetsMake(
|
||||
(self.height - self.contentSize.height) / 2,
|
||||
self.contentInset.left,
|
||||
self.contentInset.bottom,
|
||||
self.contentInset.right);
|
||||
if (self.contentInset.top > 0) {
|
||||
self.placeholderLabel.y = self.placeholderLabel.y - self.contentInset.top;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user