DisPlayers-Audio-Visualizers icon indicating copy to clipboard operation
DisPlayers-Audio-Visualizers copied to clipboard

How to move rollingview start point

Open Beautistar opened this issue 4 years ago • 5 comments

image

How can I remove or extend this line to the end of left and move visualier starting point to move at the right of edge?

Beautistar avatar May 07 '20 16:05 Beautistar

@Beautistar Did you find any solution?

rheyansh avatar Jul 18 '20 06:07 rheyansh

Yes

Beautistar avatar Jul 18 '20 13:07 Beautistar

@Beautistar Could you please share the solution. Thanks in advance!

rheyansh avatar Jul 18 '20 14:07 rheyansh

image

File replace

#import "DPRollingEqualizerView.h"

@implementation DPRollingEqualizerView

#pragma mark - Drawing

  • (void)drawRect:(CGRect)rect {

    CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSaveGState(ctx); CGRect frame = self.bounds;

    [(UIColor *)self.backgroundColor set]; UIRectFill(frame);

    CGFloat columnWidth = (rect.size.width) / (self.equalizerSettings.numOfBins - 1);

    CGFloat actualWidth = MAX(1, columnWidth (1 - 2 self.equalizerSettings.padding)); CGFloat actualPadding = MAX(0, (columnWidth - actualWidth) / 2);

    for (NSUInteger i = 0; i < self.equalizerSettings.numOfBins; i++) { CGFloat columnHeight = [[self.audioService timeHeights][i] floatValue] / 2;

      if (columnHeight <= 0)
          continue;
      CGFloat columnX = i * columnWidth;
    
      UIBezierPath *rollingPath = [[UIBezierPath alloc] init];
      rollingPath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(columnX + actualPadding,
                                                                      CGRectGetHeight(frame)/2 - columnHeight/2,
                                                                      actualWidth,
                                                                      columnHeight)
                                               cornerRadius: actualWidth];
    
      [self.equalizerBinColor setFill];
    
      [rollingPath fill];
    

    }

    [self.equalizerBinColor setStroke];

// UIBezierPath *linePath = [UIBezierPath bezierPath]; // // linePath.lineWidth = 2.0; // [linePath moveToPoint: CGPointMake(CGRectGetWidth(rect) / 2 + actualPadding, CGRectGetHeight(rect) / 2)]; // [linePath addLineToPoint: CGPointMake(CGRectGetWidth(rect), CGRectGetHeight(rect) / 2)]; // [linePath stroke];

// CGContextRestoreGState(ctx); }

@end

Beautistar avatar Jul 18 '20 14:07 Beautistar

Thanks @Beautistar It helped a lot

rheyansh avatar Jul 19 '20 11:07 rheyansh