@@ -85,8 +85,11 @@ public class DTTextField: UITextField {
85
85
return paddingX
86
86
}
87
87
88
+ fileprivate var fontHeight : CGFloat {
89
+ return ceil ( font!. lineHeight)
90
+ }
91
+
88
92
fileprivate var dtLayerHeight : CGFloat {
89
-
90
93
return showErrorLabel ? floor ( bounds. height - lblError. bounds. size. height - paddingYErrorLabel) : bounds. height
91
94
}
92
95
@@ -271,10 +274,10 @@ public class DTTextField: UITextField {
271
274
272
275
guard showErrorLabel else { return CGRect ( x: x, y: 0 , width: rect. width - paddingX, height: rect. height) }
273
276
274
- let topInset = ( rect. size. height - lblError. bounds. size. height - paddingYErrorLabel - ceil ( font! . lineHeight ) ) / 2.0
275
- let textY = ( ( rect. height - ceil ( font! . lineHeight ) ) / 2.0 ) - topInset
277
+ let topInset = ( rect. size. height - lblError. bounds. size. height - paddingYErrorLabel - fontHeight ) / 2.0
278
+ let textY = topInset - ( ( rect. height - fontHeight ) / 2.0 )
276
279
277
- return CGRect ( x: x, y: - ceil ( textY) , width: rect. size. width - paddingX, height: rect. size. height)
280
+ return CGRect ( x: x, y: floor ( textY) , width: rect. size. width - paddingX, height: rect. size. height)
278
281
}
279
282
280
283
fileprivate func insetRectForBounds( rect: CGRect ) -> CGRect {
@@ -289,9 +292,12 @@ public class DTTextField: UITextField {
289
292
return insetRectForEmptyBounds ( rect: rect)
290
293
} else {
291
294
let topInset = paddingYFloatLabel + lblFloatPlaceholder. bounds. size. height + ( paddingHeight / 2.0 )
292
- let textOriginalY = ( rect. height - font!. lineHeight) / 2.0
293
- let textY = textOriginalY - topInset
294
- return CGRect ( x: x, y: - ceil( textY) , width: rect. size. width - paddingX, height: rect. size. height)
295
+ let textOriginalY = ( rect. height - fontHeight) / 2.0
296
+ var textY = topInset - textOriginalY
297
+
298
+ if textY < 0 { textY = topInset }
299
+
300
+ return CGRect ( x: x, y: ceil ( textY) , width: rect. size. width - paddingX, height: rect. height)
295
301
}
296
302
}
297
303
}
@@ -354,10 +360,13 @@ public class DTTextField: UITextField {
354
360
override public func layoutSubviews( ) {
355
361
super. layoutSubviews ( )
356
362
363
+ CATransaction . begin ( )
364
+ CATransaction . setDisableActions ( true )
357
365
dtLayer. frame = CGRect ( x: bounds. origin. x,
358
366
y: bounds. origin. y,
359
367
width: bounds. width,
360
368
height: dtLayerHeight)
369
+ CATransaction . commit ( )
361
370
362
371
if showErrorLabel {
363
372
0 commit comments