<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;"><span><div><div><div><br></div><div>That's ugly. I'd rather write:</div><div><br></div><div> UIView.animate(withDuration:0.4) {</div><div> self.v.backgroundColor = UIColor.red()</div><div> }</div><div><br></div><div>What stops me is that `animations:` is not eligible for trailing closure syntax, because it isn't the last parameter — `completion:` is. </div></div></div></span></blockquote><div><br></div><div><span style="font-size: 12px;">Actually you can. UIView has three signatures ‘animateWithduration’:</span></div><div><span style="font-size: 12px;"><br></span></div><div><span class="kt" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145); font-family: Menlo, monospace;">class</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="kt" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145); font-family: Menlo, monospace;">func</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">animateWithDuration</span><span style="font-family: Menlo, monospace; font-size: 12px;">(</span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">_</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><code class="code-voice" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px 0px 15px; outline: 0px; padding: 0px 0px 6px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><em class="parameter-name" style="background-color: transparent; border: 0px; font-size: 0.92307em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 1.5;">duration</em></code><span style="font-family: Menlo, monospace; font-size: 12px;">: </span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/index.html#//apple_ref/swift/tdef/c:@T@NSTimeInterval" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">NSTimeInterval</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">,</span><br style="font-family: Menlo, monospace; font-size: 12px;"><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">animations</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><code class="code-voice" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px 0px 15px; outline: 0px; padding: 0px 0px 6px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><em class="parameter-name" style="background-color: transparent; border: 0px; font-size: 0.92307em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 1.5;">animations</em></code><span style="font-family: Menlo, monospace; font-size: 12px;">: () -> </span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/Swift/Reference/Swift_StandardLibrary_TypeAliases/index.html#//apple_ref/swift/tdef/s:s4Void" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">Void</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">)</span></div><div><span style="font-family: Menlo, monospace; font-size: 12px;"><br></span></div><div><span class="kt" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145); font-family: Menlo, monospace;">class</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="kt" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145); font-family: Menlo, monospace;">func</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">animateWithDuration</span><span style="font-family: Menlo, monospace; font-size: 12px;">(</span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">_</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><code class="code-voice" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px 0px 15px; outline: 0px; padding: 0px 0px 6px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><em class="parameter-name" style="background-color: transparent; border: 0px; font-size: 0.92307em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 1.5;">duration</em></code><span style="font-family: Menlo, monospace; font-size: 12px;">: </span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/index.html#//apple_ref/swift/tdef/c:@T@NSTimeInterval" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">NSTimeInterval</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">,</span><br style="font-family: Menlo, monospace; font-size: 12px;"><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">animations</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><code class="code-voice" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px 0px 15px; outline: 0px; padding: 0px 0px 6px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><em class="parameter-name" style="background-color: transparent; border: 0px; font-size: 0.92307em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 1.5;">animations</em></code><span style="font-family: Menlo, monospace; font-size: 12px;">: () -> </span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/Swift/Reference/Swift_StandardLibrary_TypeAliases/index.html#//apple_ref/swift/tdef/s:s4Void" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">Void</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">,</span><br style="font-family: Menlo, monospace; font-size: 12px;"><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">completion</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><code class="code-voice" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px 0px 15px; outline: 0px; padding: 0px 0px 6px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><em class="parameter-name" style="background-color: transparent; border: 0px; font-size: 0.92307em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 1.5;">completion</em></code><span style="font-family: Menlo, monospace; font-size: 12px;">: ((</span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/Swift/Reference/Swift_Bool_Structure/index.html#//apple_ref/swift/struct/s:Sb" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">Bool</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">) -> </span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/Swift/Reference/Swift_StandardLibrary_TypeAliases/index.html#//apple_ref/swift/tdef/s:s4Void" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">Void</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">)?)</span></div><div><span style="font-family: Menlo, monospace; font-size: 12px;"><br></span></div><div><span class="kt" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145); font-family: Menlo, monospace;">class</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="kt" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145); font-family: Menlo, monospace;">func</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">animateWithDuration</span><span style="font-family: Menlo, monospace; font-size: 12px;">(</span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">_</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><code class="code-voice" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px 0px 15px; outline: 0px; padding: 0px 0px 6px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><em class="parameter-name" style="background-color: transparent; border: 0px; font-size: 0.92307em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 1.5;">duration</em></code><span style="font-family: Menlo, monospace; font-size: 12px;">: </span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/index.html#//apple_ref/swift/tdef/c:@T@NSTimeInterval" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">NSTimeInterval</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">,</span><br style="font-family: Menlo, monospace; font-size: 12px;"><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">delay</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><code class="code-voice" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px 0px 15px; outline: 0px; padding: 0px 0px 6px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><em class="parameter-name" style="background-color: transparent; border: 0px; font-size: 0.92307em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 1.5;">delay</em></code><span style="font-family: Menlo, monospace; font-size: 12px;">: </span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/index.html#//apple_ref/swift/tdef/c:@T@NSTimeInterval" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">NSTimeInterval</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">,</span><br style="font-family: Menlo, monospace; font-size: 12px;"><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">options</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><code class="code-voice" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px 0px 15px; outline: 0px; padding: 0px 0px 6px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><em class="parameter-name" style="background-color: transparent; border: 0px; font-size: 0.92307em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 1.5;">options</em></code><span style="font-family: Menlo, monospace; font-size: 12px;">: </span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/swift/struct/c:@E@UIViewAnimationOptions" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">UIViewAnimationOptions</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">,</span><br style="font-family: Menlo, monospace; font-size: 12px;"><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">animations</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><code class="code-voice" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px 0px 15px; outline: 0px; padding: 0px 0px 6px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><em class="parameter-name" style="background-color: transparent; border: 0px; font-size: 0.92307em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 1.5;">animations</em></code><span style="font-family: Menlo, monospace; font-size: 12px;">: () -> </span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/Swift/Reference/Swift_StandardLibrary_TypeAliases/index.html#//apple_ref/swift/tdef/s:s4Void" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">Void</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">,</span><br style="font-family: Menlo, monospace; font-size: 12px;"><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><span class="nl" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace;">completion</span><span style="font-family: Menlo, monospace; font-size: 12px;"> </span><code class="code-voice" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px 0px 15px; outline: 0px; padding: 0px 0px 6px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><em class="parameter-name" style="background-color: transparent; border: 0px; font-size: 0.92307em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 1.5;">completion</em></code><span style="font-family: Menlo, monospace; font-size: 12px;">: ((</span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/Swift/Reference/Swift_Bool_Structure/index.html#//apple_ref/swift/struct/s:Sb" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">Bool</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">) -> </span><span class="n" style="background-color: transparent; border: 0px; font-size: 12px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); font-family: Menlo, monospace;"><a href="file:///Users/rimliu/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.iOS.docset/Contents/Resources/Documents/documentation/Swift/Reference/Swift_StandardLibrary_TypeAliases/index.html#//apple_ref/swift/tdef/s:s4Void" data-renderer-version="2" style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">Void</a></span><span style="font-family: Menlo, monospace; font-size: 12px;">)?)</span></div><div><span style="font-family: Menlo, monospace; font-size: 12px;"><br></span></div><div><span style="font-family: Menlo, monospace; font-size: 12px;">so your version is valid.</span></div><div><span style="font-family: Menlo, monospace; font-size: 12px;"><br></span></div><div><span style="font-family: Menlo, monospace; font-size: 12px;"><br></span></div><div><span style="font-size: 12px;">Best regards,</span></div><div><span style="font-size: 12px;">Rimantas</span></div>