Skip to content

Commit 9a2c578

Browse files
committed
fix: ios width
1 parent dda2cee commit 9a2c578

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

ios/RNDateTimePicker.m

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,48 @@ - (void)setDate:(NSDate *)date {
7272
}
7373
}
7474

75+
- (void)setFrame:(CGRect)frame {
76+
// Enforce minimum dimensions to prevent UIKit warnings
77+
// UIDatePicker requires minimum 280pt width
78+
CGRect adjustedFrame = frame;
79+
80+
if (adjustedFrame.size.width > 0 && adjustedFrame.size.width < 280) {
81+
adjustedFrame.size.width = 280;
82+
}
83+
84+
// UICalendarView (inline style) requires minimum 330pt height
85+
if (@available(iOS 14.0, *)) {
86+
if (self.preferredDatePickerStyle == UIDatePickerStyleInline) {
87+
if (adjustedFrame.size.height > 0 && adjustedFrame.size.height < 330) {
88+
adjustedFrame.size.height = 330;
89+
}
90+
}
91+
}
92+
93+
[super setFrame:adjustedFrame];
94+
}
95+
96+
- (void)setBounds:(CGRect)bounds {
97+
// Enforce minimum dimensions to prevent UIKit warnings
98+
// UIDatePicker requires minimum 280pt width
99+
CGRect adjustedBounds = bounds;
100+
101+
if (adjustedBounds.size.width > 0 && adjustedBounds.size.width < 280) {
102+
adjustedBounds.size.width = 280;
103+
}
104+
105+
// UICalendarView (inline style) requires minimum 330pt height
106+
if (@available(iOS 14.0, *)) {
107+
if (self.preferredDatePickerStyle == UIDatePickerStyleInline) {
108+
if (adjustedBounds.size.height > 0 && adjustedBounds.size.height < 330) {
109+
adjustedBounds.size.height = 330;
110+
}
111+
}
112+
}
113+
114+
[super setBounds:adjustedBounds];
115+
}
116+
75117
- (CGSize)intrinsicContentSize {
76118
CGSize size = [super intrinsicContentSize];
77119

0 commit comments

Comments
 (0)