这是我的动画方法(PreloaderView.swift)
public func performAction(action: PreloaderAction)
{
let highOpacity = CABasicAnimation.init(keyPath: "opacity")
let middleOpacity = CABasicAnimation.init(keyPath: "opacity")
let lowOpacity = CABasicAnimation.init(keyPath: "opacity")
if action == .PreloaderActionNone {
self.thirdShape.removeAllAnimations()
self.firstShape.opacity = 0.3;
self.secondShape.opacity = 0.5
self.thirdShape.opacity = 1.0
} else if action == .PreloaderActionFailure {
UIView.animateWithDuration(2, animations: {
self.thirdShape.strokeColor = UIColor.redColor().CGColor
}) {(completed : Bool) in
self.thirdShape.strokeColor = self.ringColor.CGColor
}
}
if action == .PreloaderActionStart {
highOpacity.fromValue = 0.0
highOpacity.toValue = 1.0
highOpacity.duration = animationDuration
highOpacity.autoreverses = true
highOpacity.repeatCount = .infinity
self.secondShape.addAnimation(highOpacity, …Run Code Online (Sandbox Code Playgroud) 我动态创建UIlabels,对于第一个标签,我使用Bold风格.
for (int i = 0; i < vehicles.count; ++i) {
CGRect labelRect = CGRectMake(i * (self.frame.size.width / vehicles.count),
3, self.frame.size.width / vehicles.count,
13);
UILabel *label = [[UILabel alloc] initWithFrame:labelRect];
label.textColor = thumbColor;
label.textAlignment = NSTextAlignmentCenter;
label.text = vehicles[i].vehicleClass;
UIFont *labelFont;
if (i == 0) {
labelFont = [UIFont fontWithName:@"Avenir Next-Bold" size:9.0];
} else {
labelFont = [UIFont fontWithName:@"Avenir Next" size:9.0];
}
label.font = labelFont;
[vehiclesLabels addObject:label];
[self addSubview:label];
}
Run Code Online (Sandbox Code Playgroud)
但它画得像这样
为什么第一个标签更大?