Skip to content

Commit

Permalink
fixed drawing for default play button
Browse files Browse the repository at this point in the history
  • Loading branch information
lappp9 committed Jan 28, 2016
1 parent 3b38559 commit 83f9be2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
25 changes: 12 additions & 13 deletions AsyncDisplayKit/Private/ASDefaultPlayButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@ - (instancetype)init

+ (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) {
Expand All @@ -55,12 +56,10 @@ + (void)drawRect:(CGRect)bounds withParameters:(id<NSObject>)parameters isCancel
// 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];
Expand Down
2 changes: 1 addition & 1 deletion examples/Videos/Sample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (ASVideoNode *)guitarVideo;

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;

Expand Down

0 comments on commit 83f9be2

Please sign in to comment.