나는 drawRect로 구현 된 간단한 사용자 정의 UIView (사각형)가 있습니다.사용자 정의 UIView 애니메이션
보기는 두 가지 값에서 가져옵니다. 의 drawRect에서 CurrentValue에와 maxValue를
는 : 얼마나 많은 CurrentValue에 maxValue를의
하는 구형의 높이가 나타내는입니다 :
if(currentValue > maxValue)
currentValue = maxValue;
float scale = currentValue/maxValue;
//Draw the rect
CGContextBeginPath(context);
CGContextMoveToPoint(context, self.bounds.origin.x, self.bounds.size.height);
CGContextAddLineToPoint(context, self.bounds.size.width, self.bounds.size.height);
CGContextAddLineToPoint(context, self.bounds.size.width, self.bounds.size.height-(self.bounds.size.height*scale));
CGContextAddLineToPoint(context, self.bounds.origin.x, self.bounds.size.height-(self.bounds.size.height*scale));
CGContextClosePath(context);
CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0);
CGContextFillPath(context);
CGContextStrokePath(context);
나는 CurrentValue에 등을 변경하는 UISlider로 설정에게의 ViewController를했습니다 변경 될 때마다 setNeedsDisplay가 호출됩니다. 이 부분은 잘 작동합니다. 슬라이더를 사용할 때 rect는 높이를 계획대로 정확하게 변경합니다.
내 질문은 .. 나는 애니메이션 사이의 전환을 원합니다. 가장 좋은 방법은 무엇입니까?
감사
감사합니다. 간단한 UIView rect를 사용하고 UIView animateWithDuration .. 대신 프레임을 변경 한 다음 컨트롤러가 모든 작업을 수행하도록했습니다. – Jach0