<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TiMoch &#187; animation</title>
	<atom:link href="https://timoch.com/blog/tag/animation/feed/" rel="self" type="application/rss+xml" />
	<link>https://timoch.com/blog</link>
	<description>on edge</description>
	<lastBuildDate>Tue, 29 Apr 2014 15:02:50 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.9.40</generator>
	<item>
		<title>Animate a UIView out of thin air</title>
		<link>https://timoch.com/blog/2012/09/animate-a-uiview-out-of-thin-air/</link>
		<comments>https://timoch.com/blog/2012/09/animate-a-uiview-out-of-thin-air/#comments</comments>
		<pubDate>Sat, 15 Sep 2012 12:44:00 +0000</pubDate>
		<dc:creator><![CDATA[timoch]]></dc:creator>
				<category><![CDATA[Mobile Development]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[objc]]></category>
		<category><![CDATA[uiview]]></category>

		<guid isPermaLink="false">http://www.timoch.com/blog/?p=88</guid>
		<description><![CDATA[Today, I was trying to animate a menu-like view so that it slides out of a bar of buttons at the bottom of my application. Easy enough, I read some documentation about animations here. And I end up with code similar to this in the controller responsible for the sliding view: [crayon-69d57bc8a5e0e711846767/] Nothing spectacular. I [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Today, I was trying to animate a menu-like view so that it slides out of a bar of buttons at the bottom of my application.</p>
<p>Easy enough, I read some documentation about animations <a href="http://developer.apple.com/library/ios/#documentation/windowsviews/conceptual/viewpg_iphoneos/animatingviews/animatingviews.html">here</a>. And I end up with code similar to this in the controller responsible for the sliding view:</p>
<p></p><pre class="crayon-plain-tag">CGRect frame = self.view.frame;
// make sure the view initially sits outside the screen
frame.origin.y = 480;
self.view.frame = frame;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
frame.origin.y = referenceFrame.origin.y - frame.size.height;
self.view.frame = frame;
[UIView commitAnimations];</pre><p> </p>
<p>Nothing spectacular. I make sure the initial view in outside the visible part of the screen and I animate the view into its final position.</p>
<p>Now my view slides up but in my case the final position is on top of another view. So there is content below its final position. My sliding menu ends up sliding up in front of the button bar and all. Not so nice but the solution is simple right ? just animate the height of the view as well. It will appear to slide out of the whichever view you selected as a reference view.</p>
<p></p><pre class="crayon-plain-tag">CGRect final = self.view.frame;

// before animating, set the view height to 0
CGRect initial = final;
initial.origin.y = self.referenceFrame.origin.y;
initial.size.height = 0;
self.view.frame = initial;

[UIView beginAnimations:@"showShareMenu" context:NULL];
[UIView setAnimationDuration:1];
final.origin.y = self.referenceFrame.origin.y - final.size.height;
final.size.height = final.size.height;
self.view.frame = final;
[UIView commitAnimations];</pre><p> </p>
<p>Well not so fast !! my view has kept its initial size. I had to search for a while. My view was not resizing because of its content. In the end, I had to change my views property so that it &#8216;Clips Subviews&#8217;</p>
<p><a href="http://www.timoch.com/blog/wp-content/uploads/2012/09/clip-subviews1.png"><img class="aligncenter size-full wp-image-106" title="clip-subviews" src="http://www.timoch.com/blog/wp-content/uploads/2012/09/clip-subviews1.png" alt="" width="313" height="467" /></a></p>
<p>TiMoch <em>on edge</em></p>
]]></content:encoded>
			<wfw:commentRss>https://timoch.com/blog/2012/09/animate-a-uiview-out-of-thin-air/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
