Skip to content

Commit 36c1274

Browse files
Add clipping mask
Videos are not perfectly aligned. When zoomed in, sometimes there are visible lines of adjacent videos on the endges. We can set a mask, to hide some amount of pixels from each side.
1 parent 46fbe42 commit 36c1274

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

iloveusomuch/VideosViewController.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#define ANIMATION_DURATION 0.3
66
#define ANIMATION_CURVE UIViewAnimationOptionCurveEaseOut
7+
#define CROP_VIDEOS_PX 2
78

89
@implementation VideoView
910
@synthesize videosPlayer;
@@ -239,6 +240,19 @@ - (void)viewDidLayoutSubviews {
239240
setCategory: AVAudioSessionCategoryPlayback
240241
error: nil];
241242
[self.videosPlayer setFrame: newBounds];
243+
244+
// Videos are not perfectly aligned. When zoomed in, sometimes there are visible lines
245+
// of adjacent videos on the endges. We can set a mask, to hide some pixels from each side
246+
CAShapeLayer* levelLayer = [CAShapeLayer layer];
247+
UIBezierPath* path = [UIBezierPath bezierPathWithRect:
248+
CGRectMake([[self videoView] bounds].origin.x + CROP_VIDEOS_PX,
249+
[[self videoView] bounds].origin.y + CROP_VIDEOS_PX,
250+
[[self videoView] bounds].size.width - CROP_VIDEOS_PX * 2,
251+
[[self videoView] bounds].size.height - CROP_VIDEOS_PX * 2)
252+
];
253+
[levelLayer setPath: path.CGPath];
254+
[[[self videoView] layer] setMask: levelLayer];
255+
242256
[[self.videosPlayer player] play];
243257
}
244258

0 commit comments

Comments
 (0)