Unifies bubble sizes for media bubbles

On iPhone 6 and above, media bubble sizes are 10% wider
On iPhone 5s and below, media bubbles are fixed in their larger dimension and the other dimension is calculated based on the aspect ratio of the underlying image (clamped to a reasonable min/max height).

// FREEBIE
pull/1/head
Matthew Douglass 9 years ago
parent c958c7909c
commit 09d377f7e2

@ -13,13 +13,20 @@
@implementation JSQMediaItem (OWS)
- (CGSize)ows_adjustBubbleSize:(CGSize)bubbleSize forImage:(UIImage *)image {
double aspectRatio = image.size.height / image.size.width;
double clampedAspectRatio = [NumberUtil clamp:aspectRatio toMin:0.5 andMax:1.5];
if ([[UIDevice currentDevice] isiPhoneVersionSixOrMore]) {
bubbleSize.width *= 1.1;
bubbleSize.width *= 1.2;
bubbleSize.height = (CGFloat)(bubbleSize.width * clampedAspectRatio);
} else {
bubbleSize.width *= 0.7;
if (aspectRatio > 1) {
bubbleSize.height = bubbleSize.width;
bubbleSize.width = (CGFloat)(bubbleSize.height / clampedAspectRatio);
} else {
bubbleSize.height = (CGFloat)(bubbleSize.width * clampedAspectRatio);
}
}
double aspectRatio = image.size.height / image.size.width;
bubbleSize.height = (CGFloat)(bubbleSize.width * [NumberUtil clamp:aspectRatio toMin:0.5 andMax:1.5]);
return bubbleSize;
}

Loading…
Cancel
Save