DCRoundSwitchオブジェクトの値に基づいてビューを表示または非表示にしようとしていますが、UIViewアニメーションブロックがアニメーション化されていません。変更は即座に適用されます。また、CATransactionを使用してビューのレイヤーをアニメーション化しようとしましたが、それらの変更も即座に適用されました。同じアニメーションブロックを別の場所(たとえば、viewWillAppear :)に移動すると、アニメーションは正常に機能します。
アニメーションが機能しない理由を特定するための助けをいただければ幸いです。ありがとう!
アニメーションコードは次のとおりです。
- (void)switchValueChanged:(id)sender
{
    [UIView animateWithDuration:0.33
                     animations:^{
                         self.containerView.alpha = self.switchView.isOn ? 1 : 0;
                     }];
}
参考までに、DCRoundSwitchがスイッチ値を変更するために使用するコードを次に示します。animatedでありYES、ignoreControlEventsですNO。
- (void)setOn:(BOOL)newOn animated:(BOOL)animated ignoreControlEvents:(BOOL)ignoreControlEvents
{
    BOOL previousOn = self.on;
    on = newOn;
    ignoreTap = YES;
    [CATransaction setAnimationDuration:0.014];
    knobLayer.gripped = YES;
    // setup by turning off the manual clipping of the toggleLayer and setting up a layer mask.
    [self useLayerMasking];
    [self positionLayersAndMask];
    [CATransaction setCompletionBlock:^{
        [CATransaction begin];
        if (!animated)
            [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
        else
            [CATransaction setValue:(id)kCFBooleanFalse forKey:kCATransactionDisableActions];
        CGFloat minToggleX = -toggleLayer.frame.size.width / 2.0 + toggleLayer.frame.size.height / 2.0;
        CGFloat maxToggleX = -1;
        if (self.on)
        {
            toggleLayer.frame = CGRectMake(maxToggleX,
                                           toggleLayer.frame.origin.y,
                                           toggleLayer.frame.size.width,
                                           toggleLayer.frame.size.height);
        }
        else
        {
            toggleLayer.frame = CGRectMake(minToggleX,
                                           toggleLayer.frame.origin.y,
                                           toggleLayer.frame.size.width,
                                           toggleLayer.frame.size.height);
        }
        if (!toggleLayer.mask)
        {
            [self useLayerMasking];
            [toggleLayer setNeedsDisplay];
        }
        [self positionLayersAndMask];
        knobLayer.gripped = NO;
        [CATransaction setCompletionBlock:^{
            [self removeLayerMask];
            ignoreTap = NO;
            // send the action here so it get's sent at the end of the animations
            if (previousOn != on && !ignoreControlEvents)
                [self sendActionsForControlEvents:UIControlEventValueChanged];
        }];
        [CATransaction commit];
    }];
}