Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions iphone/Classes/TiUIiOSBlurView.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,30 @@ - (void)setGlassEffect_:(id)value
}
#endif

- (void)setBorderRadius_:(NSNumber *)borderRadius
- (void)setBorderRadius_:(id)borderRadius
{

#if IS_SDK_IOS_26
// The UICornerConfiguration is necessary to use the iOS 26+ glass effect API
if (@available(iOS 26.0, *)) {
blurView.cornerConfiguration = [UICornerConfiguration configurationWithRadius:[UICornerRadius fixedRadius:borderRadius.floatValue]];
NSArray<NSNumber *> *cornerArray = [TiUtils cornerArrayFromRadius:borderRadius];

if (cornerArray.count == 1) {
CGFloat fixedBorderRadius = [cornerArray.firstObject floatValue];
blurView.cornerConfiguration = [UICornerConfiguration configurationWithRadius:[UICornerRadius fixedRadius:fixedBorderRadius]];
return;
}

UICornerRadius *topLeft = [[UICornerRadius fixedRadius:cornerArray[0].floatValue] retain];
UICornerRadius *topRight = [[UICornerRadius fixedRadius:cornerArray[1].floatValue] retain];
UICornerRadius *bottomLeft = [[UICornerRadius fixedRadius:cornerArray[2].floatValue] retain];
UICornerRadius *bottomRight = [[UICornerRadius fixedRadius:cornerArray[3].floatValue] retain];

blurView.cornerConfiguration = [UICornerConfiguration configurationWithTopLeftRadius:topLeft
topRightRadius:topRight
bottomLeftRadius:bottomLeft
bottomRightRadius:bottomRight];

return;
}
#endif
Expand Down
25 changes: 6 additions & 19 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiUIView.m
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ - (void)fillFrameToRect:(TiRect *)rect
- (CAShapeLayer *)borderLayer
{
// If borderRadius has multiple values, create a custom borderlayer and add as sublayer on self.layer. Otherwise use self.layer.
NSArray *array = [self cornerArrayFromRadius:[proxy valueForUndefinedKey:@"borderRadius"]];
NSArray *array = [TiUtils cornerArrayFromRadius:[proxy valueForUndefinedKey:@"borderRadius"]];
if ((!array || array.count <= 1) && _borderLayer != self.layer) {
self.layer.mask = nil;
self.layer.borderColor = _borderLayer.strokeColor;
Expand Down Expand Up @@ -704,7 +704,7 @@ - (void)setBackgroundImage_:(id)image
bgdImageLayer = [[CALayer alloc] init];
[bgdImageLayer setFrame:[self bounds]];
bgdImageLayer.masksToBounds = YES;
NSArray *cornerRadiusArray = [self cornerArrayFromRadius:[proxy valueForUndefinedKey:@"borderRadius"]];
NSArray *cornerRadiusArray = [TiUtils cornerArrayFromRadius:[proxy valueForUndefinedKey:@"borderRadius"]];
if (cornerRadiusArray && cornerRadiusArray.count > 0) {
[self addCornerRadius:cornerRadiusArray toLayer:bgdImageLayer];
} else {
Expand Down Expand Up @@ -823,22 +823,9 @@ - (void)addCornerRadius:(NSArray *)radiusArray toLayer:(CALayer *)viewLayer
[self updateViewShadowPath];
}

- (NSArray *)cornerArrayFromRadius:(id)radius
{
NSArray *cornerRadiusArray = nil;
if ([radius isKindOfClass:[NSString class]]) {
cornerRadiusArray = [(NSString *)radius componentsSeparatedByString:@" "];
} else if ([radius isKindOfClass:[NSArray class]]) {
cornerRadiusArray = radius;
} else if ([radius isKindOfClass:[NSNumber class]]) {
cornerRadiusArray = [NSArray arrayWithObject:radius];
}
return cornerRadiusArray;
}

- (void)updateBorderRadius:(id)radius
{
NSArray *cornerRadiusArray = [self cornerArrayFromRadius:radius];
NSArray *cornerRadiusArray = [TiUtils cornerArrayFromRadius:radius];

if (!cornerRadiusArray) {
NSLog(@"[WARN] No value specified for borderRadius.");
Expand Down Expand Up @@ -948,7 +935,7 @@ - (void)setBackgroundGradient_:(id)arg
[gradientLayer setNeedsDisplayOnBoundsChange:YES];
[gradientLayer setFrame:[self bounds]];
[gradientLayer setNeedsDisplay];
NSArray *cornerRadiusArray = [self cornerArrayFromRadius:[proxy valueForUndefinedKey:@"borderRadius"]];
NSArray *cornerRadiusArray = [TiUtils cornerArrayFromRadius:[proxy valueForUndefinedKey:@"borderRadius"]];
if (cornerRadiusArray && cornerRadiusArray.count > 0) {
[self addCornerRadius:cornerRadiusArray toLayer:gradientLayer];
} else {
Expand Down Expand Up @@ -1007,7 +994,7 @@ - (CAShapeLayer *)shadowLayer
// If there is single cborderRadius, use self.layer as shadwoLayer.
// Shadow animation does not work if shadowLayer is added on self.layer.superlayer
// But in this case, shadwoLayer is self.layer. So animation will work on shadow as well.
NSArray *array = [self cornerArrayFromRadius:[proxy valueForUndefinedKey:@"borderRadius"]];
NSArray *array = [TiUtils cornerArrayFromRadius:[proxy valueForUndefinedKey:@"borderRadius"]];
if ((!array || array.count <= 1) && _shadowLayer != self.layer) {
self.layer.mask = nil;
[self assignShadowPropertyFromLayer:_shadowLayer toLayer:self.layer];
Expand All @@ -1028,7 +1015,7 @@ - (CAShapeLayer *)shadowLayer
- (UIBezierPath *)bezierPathOfView
{
if ([proxy valueForUndefinedKey:@"borderRadius"]) {
NSArray *array = [self cornerArrayFromRadius:[proxy valueForUndefinedKey:@"borderRadius"]];
NSArray *array = [TiUtils cornerArrayFromRadius:[proxy valueForUndefinedKey:@"borderRadius"]];
if (array.count > 1) {
return [self bezierPathOfSize:self.bounds.size forRadiusArray:array];
}
Expand Down
2 changes: 2 additions & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -876,4 +876,6 @@ typedef enum {
*/
+ (UIImageSymbolWeight)symbolWeightFromString:(NSString *)string NS_AVAILABLE_IOS(13_0);

+ (NSArray *)cornerArrayFromRadius:(id)radius;

@end
24 changes: 24 additions & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -2321,4 +2321,28 @@ + (UIImageSymbolWeight)symbolWeightFromString:(NSString *)string
return UIImageSymbolWeightRegular;
}

+ (NSArray *)cornerArrayFromRadius:(id)radius
{
NSArray<NSNumber *> *cornerRadiusArray = nil;

if ([radius isKindOfClass:[NSString class]]) {
NSArray<NSString *> *stringComponents = [(NSString *)radius componentsSeparatedByString:@" "];
NSMutableArray<NSNumber *> *numberArray = [NSMutableArray arrayWithCapacity:stringComponents.count];

// Properly convert string values to numbers
for (NSString *component in stringComponents) {
NSString *trimmedComponent = [component stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (trimmedComponent.length > 0) {
[numberArray addObject:@([trimmedComponent doubleValue])];
}
}
cornerRadiusArray = [numberArray copy];
} else if ([radius isKindOfClass:[NSArray class]]) {
cornerRadiusArray = radius;
} else if ([radius isKindOfClass:[NSNumber class]]) {
cornerRadiusArray = [NSArray arrayWithObject:radius];
}
return cornerRadiusArray;
}

@end
Loading