@@ -105,16 +105,65 @@ - (void)contextMenuInteraction:(UIContextMenuInteraction *)interaction willEndFo
105
105
}
106
106
}
107
107
108
- - (UITargetedPreview *)contextMenuInteraction : (UIContextMenuInteraction *)interaction previewForHighlightingMenuWithConfiguration : (UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0 )) {
109
- UIPreviewTarget* previewTarget = [[UIPreviewTarget alloc ] initWithContainer: self center: self .reactSubviews.firstObject.center];
108
+ - (UIPreviewParameters *)getPreviewParams {
110
109
UIPreviewParameters* previewParams = [[UIPreviewParameters alloc ] init ];
111
-
110
+
112
111
if (_previewBackgroundColor != nil ) {
113
- previewParams.backgroundColor = _previewBackgroundColor;
112
+ previewParams.backgroundColor = _previewBackgroundColor;
113
+ }
114
+
115
+ if (self.borderRadius > -1 ||
116
+ self.borderTopLeftRadius > -1 ||
117
+ self.borderTopRightRadius > -1 ||
118
+ self.borderBottomRightRadius > -1 ||
119
+ self.borderBottomLeftRadius > -1 ) {
120
+
121
+ CGFloat radius = self.borderRadius > -1 ? self.borderRadius : 0 ;
122
+ CGFloat topLeftRadius = self.borderTopLeftRadius > -1 ? self.borderTopLeftRadius : radius;
123
+ CGFloat topRightRadius = self.borderTopRightRadius > -1 ? self.borderTopRightRadius : radius;
124
+ CGFloat bottomRightRadius = self.borderBottomRightRadius > -1 ? self.borderBottomRightRadius : radius;
125
+ CGFloat bottomLeftRadius = self.borderBottomLeftRadius > -1 ? self.borderBottomLeftRadius : radius;
126
+
127
+ UIBezierPath *path = [UIBezierPath bezierPath ];
128
+ CGRect bounds = self.bounds ;
129
+
130
+ [path moveToPoint: CGPointMake (CGRectGetMinX (bounds) + topLeftRadius, CGRectGetMinY (bounds))];
131
+
132
+ [path addLineToPoint: CGPointMake (CGRectGetMaxX (bounds) - topRightRadius, CGRectGetMinY (bounds))];
133
+ [path addQuadCurveToPoint: CGPointMake (CGRectGetMaxX (bounds), CGRectGetMinY (bounds) + topRightRadius)
134
+ controlPoint: CGPointMake (CGRectGetMaxX (bounds), CGRectGetMinY (bounds))];
135
+
136
+ [path addLineToPoint: CGPointMake (CGRectGetMaxX (bounds), CGRectGetMaxY (bounds) - bottomRightRadius)];
137
+ [path addQuadCurveToPoint: CGPointMake (CGRectGetMaxX (bounds) - bottomRightRadius, CGRectGetMaxY (bounds))
138
+ controlPoint: CGPointMake (CGRectGetMaxX (bounds), CGRectGetMaxY (bounds))];
139
+
140
+ [path addLineToPoint: CGPointMake (CGRectGetMinX (bounds) + bottomLeftRadius, CGRectGetMaxY (bounds))];
141
+ [path addQuadCurveToPoint: CGPointMake (CGRectGetMinX (bounds), CGRectGetMaxY (bounds) - bottomLeftRadius)
142
+ controlPoint: CGPointMake (CGRectGetMinX (bounds), CGRectGetMaxY (bounds))];
143
+
144
+ [path addLineToPoint: CGPointMake (CGRectGetMinX (bounds), CGRectGetMinY (bounds) + topLeftRadius)];
145
+ [path addQuadCurveToPoint: CGPointMake (CGRectGetMinX (bounds) + topLeftRadius, CGRectGetMinY (bounds))
146
+ controlPoint: CGPointMake (CGRectGetMinX (bounds), CGRectGetMinY (bounds))];
147
+
148
+ [path closePath ];
149
+
150
+ previewParams.visiblePath = path;
114
151
}
152
+
153
+
154
+ if (self.disableShadow ) {
155
+ previewParams.shadowPath = [UIBezierPath bezierPath ];
156
+ }
157
+
158
+ return previewParams;
159
+ }
115
160
161
+ - (UITargetedPreview *)contextMenuInteraction : (UIContextMenuInteraction *)interaction previewForHighlightingMenuWithConfiguration : (UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0 )) {
162
+ UIPreviewTarget* previewTarget = [[UIPreviewTarget alloc ] initWithContainer: self center: self .reactSubviews.firstObject.center];
163
+
164
+
116
165
return [[UITargetedPreview alloc ] initWithView: self .reactSubviews.firstObject
117
- parameters: previewParams
166
+ parameters: [ self getPreviewParams ]
118
167
target: previewTarget];
119
168
}
120
169
@@ -127,14 +176,9 @@ - (UITargetedPreview *)contextMenuInteraction:(UIContextMenuInteraction *)intera
127
176
}
128
177
129
178
UIPreviewTarget* previewTarget = [[UIPreviewTarget alloc ] initWithContainer: self center: hostView.center];
130
- UIPreviewParameters* previewParams = [[UIPreviewParameters alloc ] init ];
131
-
132
- if (_previewBackgroundColor != nil ) {
133
- previewParams.backgroundColor = _previewBackgroundColor;
134
- }
135
179
136
180
return [[UITargetedPreview alloc ] initWithView: hostView
137
- parameters: previewParams
181
+ parameters: [ self getPreviewParams ]
138
182
target: previewTarget];
139
183
}
140
184
0 commit comments