Search code examples
iosobjective-cprogress-baruiprogressviewuiprogressbar

Width and height of progressView


How can I create progressView with width 100 and height 200. And rotate progressView on 90 degrees?

It does not work together. Or progressView is turned by 90 or change size

self.progressView.transform = CGAffineTransformMakeRotation(M_PI_2);
    CGAffineTransform transform = CGAffineTransformMakeScale(1.0f, 3.0f);
    _progressView.transform = transform;

Solution

  • You need to chain your transformations. In your sample, the 2nd assignment to transform effectively overwrites the first one. This one works:

    UIProgressView *progressBar = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
    progressBar.frame = CGRectMake(50, 100, 100, 50);
    CGAffineTransform t = CGAffineTransformMakeRotation(M_PI_2);
    t = CGAffineTransformScale(t, 1.0f, 50.0f);
    progressBar.transform = t;
    [self.view addSubview:progressBar];