fixed drawing for default play button

This commit is contained in:
Luke Parham 2016-01-28 01:35:08 -08:00
parent 3b38559c4d
commit 83f9be256b
2 changed files with 13 additions and 14 deletions

View File

@ -23,20 +23,21 @@
+ (void)drawRect:(CGRect)bounds withParameters:(id<NSObject>)parameters isCancelled:(asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing
{
CGRect buttonBounds;
buttonBounds = CGRectMake(bounds.size.width/4, bounds.size.height/4, bounds.size.width/2, bounds.size.height/2);
CGFloat originX = bounds.size.width/4;
CGRect buttonBounds = CGRectMake(originX, bounds.size.height/4, bounds.size.width/2, bounds.size.height/2);
CGFloat widthHeight = buttonBounds.size.width;
if (bounds.size.width < bounds.size.height) {
//then use the width to determine the rect size then calculate the origin x y
buttonBounds = CGRectMake(bounds.size.width/4, bounds.size.width/4, bounds.size.width/2, bounds.size.width/2);
widthHeight = bounds.size.width/2;
originX = (bounds.size.width - widthHeight)/2;
buttonBounds = CGRectMake(originX, (bounds.size.height - widthHeight)/2, widthHeight, widthHeight);
}
if (bounds.size.width > bounds.size.height) {
//use the height
buttonBounds = CGRectMake(bounds.size.height/4, bounds.size.height/4, bounds.size.height/2, bounds.size.height/2);
}
if (bounds.size.width == bounds.size.height) {
//square so easy
buttonBounds = CGRectMake(bounds.size.width/4, bounds.size.height/4, bounds.size.width/2, bounds.size.height/2);
widthHeight = bounds.size.height/2;
originX = (bounds.size.width - widthHeight)/2;
buttonBounds = CGRectMake(originX, (bounds.size.height - widthHeight)/2, widthHeight, widthHeight);
}
if (!isRasterizing) {
@ -55,12 +56,10 @@
// Triangle Drawing
CGContextSaveGState(context);
CGFloat buttonWidth = buttonBounds.size.width;
UIBezierPath *trianglePath = [UIBezierPath bezierPath];
[trianglePath moveToPoint:CGPointMake(bounds.size.width/4 + buttonWidth/3, bounds.size.height/4 + (bounds.size.height/2)/4)];
[trianglePath addLineToPoint:CGPointMake(bounds.size.width/4 + buttonWidth/3, bounds.size.height - bounds.size.height/4 - (bounds.size.height/2)/4)];
[trianglePath addLineToPoint:CGPointMake(bounds.size.width - bounds.size.width/4 - buttonWidth/4, bounds.size.height/2)];
[trianglePath moveToPoint:CGPointMake(originX + widthHeight/3, bounds.size.height/4 + (bounds.size.height/2)/4)];
[trianglePath addLineToPoint:CGPointMake(originX + widthHeight/3, bounds.size.height - bounds.size.height/4 - (bounds.size.height/2)/4)];
[trianglePath addLineToPoint:CGPointMake(bounds.size.width - originX - widthHeight/4, bounds.size.height/2)];
[trianglePath closePath];
[[UIColor colorWithWhite:0.9 alpha:0.9] setFill];

View File

@ -37,7 +37,7 @@
videoNode.asset = [AVAsset assetWithURL:[NSURL URLWithString:@"https://files.parsetfss.com/8a8a3b0c-619e-4e4d-b1d5-1b5ba9bf2b42/tfss-3045b261-7e93-4492-b7e5-5d6358376c9f-editedLiveAndDie.mov"]];
videoNode.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/3);
videoNode.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height/3);
videoNode.gravity = AVLayerVideoGravityResizeAspectFill;