Changing timing for looping uiview animation

2016-02-25 Thread Eric Dolecki
I have a heart rate looping scaling animation. 
Every 5 seconds I get new data. How can I adjust the looping scale rate without 
removing the animation before setting the new rate without hiccups?

Sent from Outlook on my phone.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Coordinating animation of layers with a UIView animation

2012-11-06 Thread Roland King
I have a UIView which frame I am animating to a new location/size using [ 
UIView animateWithDuration:animations ]. The view's layer has a custom sublayer 
which it's laying out either in layoutSubviews or layoutSublayersOfLayer:, 
either seems to work. That sublayer is also moving to a new position depending 
on the new UIView bounds. What I want is the two animations to go together, 
using whatever the duration set in the UIView's animateWithDuration:animations: 
call because that is the point at which I know how long the animation needs to 
be. 

The only way I've found to do this so far seems really hacky, to nest a 
CATransaction within the UIView animation and give them the same time, is there 
a better way to accomplish something like this? 

NSTimeInterval interval = 2f;

[ UIView animateWithDuration:interval animations:^{
[ CATransaction begin ];
[ CATransaction setAnimationDuration:interval ];
self.faceView.frame=faceViewFrame;
[ CATransaction commit ];
} ];

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Coordinating animation of layers with a UIView animation

2012-11-06 Thread Luke Hiesterman
After setting up your UIView animation, you can introspect the animation timing 
by looking at the respective view's layer.animations. Your can then apply that 
animation to your sublayer. 

For bonus points, just start using a subview instead of a sublayer :)

Luke

On Nov 6, 2012, at 5:09 AM, Roland King r...@rols.org wrote:

 I have a UIView which frame I am animating to a new location/size using [ 
 UIView animateWithDuration:animations ]. The view's layer has a custom 
 sublayer which it's laying out either in layoutSubviews or 
 layoutSublayersOfLayer:, either seems to work. That sublayer is also moving 
 to a new position depending on the new UIView bounds. What I want is the two 
 animations to go together, using whatever the duration set in the UIView's 
 animateWithDuration:animations: call because that is the point at which I 
 know how long the animation needs to be. 
 
 The only way I've found to do this so far seems really hacky, to nest a 
 CATransaction within the UIView animation and give them the same time, is 
 there a better way to accomplish something like this? 
 
NSTimeInterval interval = 2f;

[ UIView animateWithDuration:interval animations:^{
[ CATransaction begin ];
[ CATransaction setAnimationDuration:interval ];
self.faceView.frame=faceViewFrame;
[ CATransaction commit ];
} ];
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com
 
 This email sent to luket...@apple.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation (backgroundColor) + drawRect:

2011-03-03 Thread Roland King
As ever, thanks very much David. I figured there was *something* going on when 
drawRect: was defined but I wouldn't have figured out what without this help. 

In this case a crossfade in every case for that particular view works 
perfectly, I implemented what you suggested and it looks so much better, it's 
amazing the difference that even a .3-.5 second smooth transition can make, 
just takes the edge off something which was quite harsh before, looks much more 
professional. 

Got the point (again) on using simple subviews when possible, a mistake I've 
made before. In this particular case I don't think that was going to work, but 
I'm very happy with what I have now. 

Andreas, thanks for your reply too. You had pretty much exactly the same 
thoughts I did and we both tried the same ideas, with the same 
..AllowAnimatedContent etc and got the same results; hope David's reply was 
useful to you too, it goes in my 'keepers' file. 

On 03-Mar-2011, at 5:10 AM, David Duncan wrote:

 On Mar 2, 2011, at 5:12 AM, Roland King wrote:
 
 I was trying to animate the backgroundColor of one of my UIView subclasses 
 yesterday using 
 
  [ UIView animateWithDuration:2.0 animations:^{ [ myView 
 setBackgroundColor:someColor ]; } ];
 
 but no matter what the duration set, the background color was changing 
 instantly. Whilst looking to see if there were two places I called 
 setBackgroundColor: (there weren't) I realized that my UIView subclass has 
 its own drawRect: method (this view is basically a piece of paper with some 
 lines drawn on it, so it needs a custom drawRect: method). Commenting that 
 out, the view background animated properly, but of course I had no content. 
 Even just adding an empty drawRect: method was enough to defeat the 
 animation. 
 
 
 When you implement -drawRect:, the background color of your view is then 
 drawn into the associated CALayer, rather than just being set on the CALayer 
 as a style property. Now Core Animation can animate both transitions, but 
 UIView disables the animation of a layer's contents, which thus prevents you 
 from getting a contents crossfade (as in the vast majority of cases this 
 wouldn't be what you want).
 
 The crossfade may be exactly what you want in this case. Likely the best way 
 to defeat UIView's override in this case may be to create a subclass of 
 CALayer that overrides -actionForKey:. In that override, you would check for 
 the @contents key and return a CABasicAnimation ([CABasicAnimation 
 animation] should do it) and in all other cases return what the default 
 implementation does. This has the downside that you will *always* cross fade 
 and you won't be able to integrate with UIKit's animation APIs (you just get 
 animation for contents on all the time).
 
 Another solution would be to use a super view that contains just the 
 background color and have your lines composited over it (assuming they are 
 simple lines this could be done with simple subviews that are sized for each 
 line). This would allow you to avoid -drawRect: entirely, which would allow 
 you to animate the background color and may offer some memory usage benefits 
 (if you can use subviews). 
 --
 David Duncan
 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


UIView animation (backgroundColor) + drawRect:

2011-03-02 Thread Roland King
I was trying to animate the backgroundColor of one of my UIView subclasses 
yesterday using 

[ UIView animateWithDuration:2.0 animations:^{ [ myView 
setBackgroundColor:someColor ]; } ];

but no matter what the duration set, the background color was changing 
instantly. Whilst looking to see if there were two places I called 
setBackgroundColor: (there weren't) I realized that my UIView subclass has its 
own drawRect: method (this view is basically a piece of paper with some lines 
drawn on it, so it needs a custom drawRect: method). Commenting that out, the 
view background animated properly, but of course I had no content. Even just 
adding an empty drawRect: method was enough to defeat the animation. 

My assumption is that if there is no custom drawing, the view can smoothly 
animate its layer between the two colors, and animate any other simple 
properties, but if there is custom drawing, it doesn't want to call that 
constantly as it animates the color change, so animation doesn't happen. 

Is there anything I missed which will make this work,? I was thinking that the 
other transition animation methods ( [ UIView transitionWithView: .. ] ) take a 
'before' and 'after' snapshot and then, if you are flipping, animate one away, 
and one in. I perhaps expected that UIView to do basically that, and crossfade 
the old view out and the new one in, but I see no option for that, just flips 
and curls, I want fade. This would be more generally useful than just this 
example. 

Obviously I have a few other options including building an entirely new UIView 
on a color change, adding them both and fading their alphas in and out, or 
splitting my 'paper' into a background view and an otherwise-clear lines view. 
That may well be the right way to go with this, however I was interested to 
know if there was some part of UIView animation which would automatically 
handle a smooth transition of one single UIView between two drawn states. 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation (backgroundColor) + drawRect:

2011-03-02 Thread Andreas Grosam

On Mar 2, 2011, at 2:12 PM, Roland King wrote:

 I was trying to animate the backgroundColor of one of my UIView subclasses 
 yesterday using 
 
   [ UIView animateWithDuration:2.0 animations:^{ [ myView 
 setBackgroundColor:someColor ]; } ];
 
 but no matter what the duration set, the background color was changing 
 instantly. Whilst looking to see if there were two places I called 
 setBackgroundColor: (there weren't) I realized that my UIView subclass has 
 its own drawRect: method (this view is basically a piece of paper with some 
 lines drawn on it, so it needs a custom drawRect: method). Commenting that 
 out, the view background animated properly, but of course I had no content. 
 Even just adding an empty drawRect: method was enough to defeat the 
 animation. 
 
 My assumption is that if there is no custom drawing, the view can smoothly 
 animate its layer between the two colors, and animate any other simple 
 properties, but if there is custom drawing, it doesn't want to call that 
 constantly as it animates the color change, so animation doesn't happen. 
 
 Is there anything I missed which will make this work,? I was thinking that 
 the other transition animation methods ( [ UIView transitionWithView: .. ] ) 
 take a 'before' and 'after' snapshot and then, if you are flipping, animate 
 one away, and one in. I perhaps expected that UIView to do basically that, 
 and crossfade the old view out and the new one in, but I see no option for 
 that, just flips and curls, I want fade. This would be more generally useful 
 than just this example. 

Intuitively, a possibly solution would look like this:

UIView* view = self.helloView;
[UIView transitionWithView:view 
  duration:2.0 
   options:UIViewAnimationOptionAllowAnimatedContent | 
UIViewAnimationOptionTransitionNone
animations:^{ view.backgroundColor = [UIColor greenColor]; 
} 
completion:NULL];

Unfortunately, I couldn't get the background color to fade smoothly for UILabel 
or IUView whose drawRect is overridden as well. Implicit layer animations 
didn't work either.

For plain UIView instances the code above works with smooth animations, though. 
The simplest version is:

[UIView animateWithDuration:2.0 animations:^{ 
self.helloView.backgroundColor = [UIColor greenColor];
}];

 
 Obviously I have a few other options including building an entirely new 
 UIView on a color change, adding them both and fading their alphas in and 
 out, or splitting my 'paper' into a background view and an otherwise-clear 
 lines view. That may well be the right way to go with this, however I was 
 interested to know if there was some part of UIView animation which would 
 automatically handle a smooth transition of one single UIView between two 
 drawn states. 
Well, there is - but transition means the process of creating another image 
(from the original) and then move (in some animated way) from the original 
position to the target position. Fading the background color might not be a 
transition. However, when specifying the option 
UIViewAnimationOptionAllowAnimatedContent in a transition I would hope property 
changes would be simultaneously animated - and it did for UIViews.

A solution for your problem may look like this:

UIView* fromView = self.helloView;
UIView* toView = ...  // copy the fromView
toView.alpha = 0.0;
toView.backgroundColor = [UIColor greenColor]; // change the background 
color
[self.view insertSubview:toView aboveSubview:fromView];

[UIView animateWithDuration:2.0 
 animations:^{ 
 fromView.alpha = 0.0;
 toView.alpha = 1.0;
 }
 completion:^(BOOL finished){ [fromView 
removeFromSuperview]; }];

self.helloView = toView;
[toView release], toView = nil;


Regards
Andreas

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation (backgroundColor) + drawRect:

2011-03-02 Thread David Duncan
On Mar 2, 2011, at 5:12 AM, Roland King wrote:

 I was trying to animate the backgroundColor of one of my UIView subclasses 
 yesterday using 
 
   [ UIView animateWithDuration:2.0 animations:^{ [ myView 
 setBackgroundColor:someColor ]; } ];
 
 but no matter what the duration set, the background color was changing 
 instantly. Whilst looking to see if there were two places I called 
 setBackgroundColor: (there weren't) I realized that my UIView subclass has 
 its own drawRect: method (this view is basically a piece of paper with some 
 lines drawn on it, so it needs a custom drawRect: method). Commenting that 
 out, the view background animated properly, but of course I had no content. 
 Even just adding an empty drawRect: method was enough to defeat the 
 animation. 


When you implement -drawRect:, the background color of your view is then drawn 
into the associated CALayer, rather than just being set on the CALayer as a 
style property. Now Core Animation can animate both transitions, but UIView 
disables the animation of a layer's contents, which thus prevents you from 
getting a contents crossfade (as in the vast majority of cases this wouldn't be 
what you want).

The crossfade may be exactly what you want in this case. Likely the best way to 
defeat UIView's override in this case may be to create a subclass of CALayer 
that overrides -actionForKey:. In that override, you would check for the 
@contents key and return a CABasicAnimation ([CABasicAnimation animation] 
should do it) and in all other cases return what the default implementation 
does. This has the downside that you will *always* cross fade and you won't be 
able to integrate with UIKit's animation APIs (you just get animation for 
contents on all the time).

Another solution would be to use a super view that contains just the background 
color and have your lines composited over it (assuming they are simple lines 
this could be done with simple subviews that are sized for each line). This 
would allow you to avoid -drawRect: entirely, which would allow you to animate 
the background color and may offer some memory usage benefits (if you can use 
subviews). 
--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


missing features in iOS 4 block-based UIView animation

2010-09-08 Thread Matt Neuburg
The iOS 4 syntax for using Objective-C blocks with UIView animation (instead
of the old-style UIView animation block, love the confusing terminology
here) is delightful, but some features are missing:

* You can't designate a delegate, so you can't get a notification when the
animation is about to start.

* You can't specify a fixed number of repetitions. I have code that relies
on this feature (e.g. a view that shakes its head by vibrating back and
forth three times).

What are folks doing to compensate? Thx - m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring  Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation

2010-09-03 Thread Christian Ziegler
Hi!

Thanks Wyatt and Ricky for your answers. 

The views have to visible at the same time. I thought of making an image out of 
this view as well but I didn't know how. I googled a little and this is what I 
found: 

UIGraphicsBeginImageContext(myView.bounds.size);
[myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Cheers
Chris

On Sep 3, 2010, at 12:18 AM, Wyatt Webb wrote:

 
 On Sep 2, 2010, at 3:11 PM, Christian Ziegler wrote:
 
 Hi all,
 
 I could use your help because I'm running out of ideas!
 
 Here's the situation. I got this custom view on screen which I want to 
 remove from the screen by moving it outside the left border of the screen. 
 However at the same time, I want to move it back in from the right side but 
 at a different y-Coordinate. So for instance it moves out at y=44 and at the 
 same time it moves back in from the other side at y=0. 
 
 I tried several approaches and the most promising (I reckon) is to create a 
 copy of the view. This is not so easy though because UIView does not 
 implement NSCopying. My custom view also has subviews and well the animation 
 apparently gets a little confused if you animate two different (equal but 
 different object) views which share the same subviews.
 
 Has anybody the slightest idea how I could achieve this? Every tip is 
 welcome :)!
 
 Does the same view need to visible in two places at once? Or are you 
 completely removing it before it starts to reappear?
 
 If the same view needs to show up at both edges at the same time, then you'll 
 have to make some kind of copy. If the contents won't change during the 
 animation, you could just rasterize your view hierarchy and use that image to 
 act as a placeholder for one of the locations during the animation.
 
 If the view will only be in one place at one time, you could do this as a 
 two-stage animation.
 
 Set up the animation to cause the view to leave the screen and register 
 yourself as the delegate to get the completion callback.
 Upon callback, move the view to the other side of the screen (still off 
 screen) and set up an animation to move it back into view.
 
 Make sense?
 
 Wyatt

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation

2010-09-03 Thread Christian Ziegler
Hi again!

Just wanted to let you know that it works now. Thanks for the tip!

Cheers
Chris


On Sep 3, 2010, at 8:25 AM, Christian Ziegler wrote:

 Hi!
 
 Thanks Wyatt and Ricky for your answers. 
 
 The views have to visible at the same time. I thought of making an image out 
 of this view as well but I didn't know how. I googled a little and this is 
 what I found: 
 
 UIGraphicsBeginImageContext(myView.bounds.size);
 [myView.layer renderInContext:UIGraphicsGetCurrentContext()];
 UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
 UIGraphicsEndImageContext();
 
 Cheers
 Chris
 
 On Sep 3, 2010, at 12:18 AM, Wyatt Webb wrote:
 
 
 On Sep 2, 2010, at 3:11 PM, Christian Ziegler wrote:
 
 Hi all,
 
 I could use your help because I'm running out of ideas!
 
 Here's the situation. I got this custom view on screen which I want to 
 remove from the screen by moving it outside the left border of the screen. 
 However at the same time, I want to move it back in from the right side but 
 at a different y-Coordinate. So for instance it moves out at y=44 and at 
 the same time it moves back in from the other side at y=0. 
 
 I tried several approaches and the most promising (I reckon) is to create a 
 copy of the view. This is not so easy though because UIView does not 
 implement NSCopying. My custom view also has subviews and well the 
 animation apparently gets a little confused if you animate two different 
 (equal but different object) views which share the same subviews.
 
 Has anybody the slightest idea how I could achieve this? Every tip is 
 welcome :)!
 
 Does the same view need to visible in two places at once? Or are you 
 completely removing it before it starts to reappear?
 
 If the same view needs to show up at both edges at the same time, then 
 you'll have to make some kind of copy. If the contents won't change during 
 the animation, you could just rasterize your view hierarchy and use that 
 image to act as a placeholder for one of the locations during the animation.
 
 If the view will only be in one place at one time, you could do this as a 
 two-stage animation.
 
 Set up the animation to cause the view to leave the screen and register 
 yourself as the delegate to get the completion callback.
 Upon callback, move the view to the other side of the screen (still off 
 screen) and set up an animation to move it back into view.
 
 Make sense?
 
 Wyatt
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/chris.ziegler%40me.com
 
 This email sent to chris.zieg...@me.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation

2010-09-03 Thread Matt Neuburg
On Fri, 03 Sep 2010 00:11:43 +0200, Christian Ziegler chris.zieg...@me.com
said:
Hi all,

I could use your help because I'm running out of ideas!

Here's the situation. I got this custom view on screen which I want to remove
from the screen by moving it outside the left border of the screen. However at
the same time, I want to move it back in from the right side but at a different
y-Coordinate. So for instance it moves out at y=44 and at the same time it moves
back in from the other side at y=0.

I tried several approaches and the most promising (I reckon) is to create a
copy of the view. This is not so easy though because UIView does not implement
NSCopying. My custom view also has subviews and well the animation apparently
gets a little confused if you animate two different (equal but different object)
views which share the same subviews.

I'm sure it's not true that you're running out of ideas; it seems to me that
you're just avoiding the obvious: two different views that look alike. You
created this view and its subviews at some time; therefore you can do it
again. It's probably just a question of planning ahead. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation

2010-09-03 Thread Erik Buck
I would add that any graph of objects that implements the NSCoding protocol 
can also be trivially copied.  Interface Builder encodes and decodes object 
graphs when saving the xib/nib files and also when entering test interface mode.

As a blatant plug:
See Cocoa Design Patterns ISBN: 0-321-53502-2
Chapters 11, Archiving  Unarchiving, and 12 Copying.

--- On Fri, 9/3/10, Matt Neuburg m...@tidbits.com wrote:

 From: Matt Neuburg m...@tidbits.com
 Subject: Re: UIView animation
 To: Christian Ziegler chris.zieg...@me.com
 Cc: cocoa-dev@lists.apple.com
 Date: Friday, September 3, 2010, 11:50 AM
 On Fri, 03 Sep 2010 00:11:43 +0200,
 Christian Ziegler chris.zieg...@me.com
 said:
 Hi all,
 
 I could use your help because I'm running out of
 ideas!
 
 Here's the situation. I got this custom view on screen
 which I want to remove
 from the screen by moving it outside the left border of the
 screen. However at
 the same time, I want to move it back in from the right
 side but at a different
 y-Coordinate. So for instance it moves out at y=44 and at
 the same time it moves
 back in from the other side at y=0.
 
 I tried several approaches and the most promising (I
 reckon) is to create a
 copy of the view. This is not so easy though because UIView
 does not implement
 NSCopying. My custom view also has subviews and well the
 animation apparently
 gets a little confused if you animate two different (equal
 but different object)
 views which share the same subviews.
 
 I'm sure it's not true that you're running out of ideas; it
 seems to me that
 you're just avoiding the obvious: two different views that
 look alike. You
 created this view and its subviews at some time; therefore
 you can do it
 again. It's probably just a question of planning ahead. m.
 
 -- 
 matt neuburg, phd = m...@tidbits.com,
 http://www.tidbits.com/matt/
 A fool + a tool + an autorelease pool = cool!
 AppleScript: the Definitive Guide - Second Edition!
 http://www.tidbits.com/matt/default.html#applescriptthings
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to
 the list.
 Contact the moderators at
 cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/erik.buck%40sbcglobal.net
 
 This email sent to erik.b...@sbcglobal.net
 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


UIView animation

2010-09-02 Thread Christian Ziegler
Hi all,

I could use your help because I'm running out of ideas!

Here's the situation. I got this custom view on screen which I want to remove 
from the screen by moving it outside the left border of the screen. However at 
the same time, I want to move it back in from the right side but at a different 
y-Coordinate. So for instance it moves out at y=44 and at the same time it 
moves back in from the other side at y=0. 

I tried several approaches and the most promising (I reckon) is to create a 
copy of the view. This is not so easy though because UIView does not implement 
NSCopying. My custom view also has subviews and well the animation apparently 
gets a little confused if you animate two different (equal but different 
object) views which share the same subviews.

Has anybody the slightest idea how I could achieve this? Every tip is welcome 
:)!

Cheers
Chris
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation

2010-09-02 Thread Wyatt Webb

On Sep 2, 2010, at 3:11 PM, Christian Ziegler wrote:

 Hi all,
 
 I could use your help because I'm running out of ideas!
 
 Here's the situation. I got this custom view on screen which I want to remove 
 from the screen by moving it outside the left border of the screen. However 
 at the same time, I want to move it back in from the right side but at a 
 different y-Coordinate. So for instance it moves out at y=44 and at the same 
 time it moves back in from the other side at y=0. 
 
 I tried several approaches and the most promising (I reckon) is to create a 
 copy of the view. This is not so easy though because UIView does not 
 implement NSCopying. My custom view also has subviews and well the animation 
 apparently gets a little confused if you animate two different (equal but 
 different object) views which share the same subviews.
 
 Has anybody the slightest idea how I could achieve this? Every tip is welcome 
 :)!

Does the same view need to visible in two places at once? Or are you completely 
removing it before it starts to reappear?

If the same view needs to show up at both edges at the same time, then you'll 
have to make some kind of copy. If the contents won't change during the 
animation, you could just rasterize your view hierarchy and use that image to 
act as a placeholder for one of the locations during the animation.

If the view will only be in one place at one time, you could do this as a 
two-stage animation.

Set up the animation to cause the view to leave the screen and register 
yourself as the delegate to get the completion callback.
Upon callback, move the view to the other side of the screen (still off screen) 
and set up an animation to move it back into view.

Make sense?

Wyatt___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation

2010-09-02 Thread Ricky Sharp

On Sep 2, 2010, at 5:11 PM, Christian Ziegler wrote:

 I could use your help because I'm running out of ideas!
 
 Here's the situation. I got this custom view on screen which I want to remove 
 from the screen by moving it outside the left border of the screen. However 
 at the same time, I want to move it back in from the right side but at a 
 different y-Coordinate. So for instance it moves out at y=44 and at the same 
 time it moves back in from the other side at y=0. 
 
 I tried several approaches and the most promising (I reckon) is to create a 
 copy of the view. This is not so easy though because UIView does not 
 implement NSCopying. My custom view also has subviews and well the animation 
 apparently gets a little confused if you animate two different (equal but 
 different object) views which share the same subviews.
 
 Has anybody the slightest idea how I could achieve this? Every tip is welcome 
 :)!

Capture the view you want to animate into a UIImage.  Add two image views with 
that image to the view hierarchy.  One will be directly over your original view 
and the other will offscreen to the right.

Hide your original view.  Then, animate both image views as needed.  When 
animation ends, unhide the original view, then remove both image views.

Other notes...

You may want to ensure that when your original view is hidden, its container 
view has say a black background (or whatever background you want during the 
animation).

Note that by taking static images of your original view, no animations on that 
view itself will run during the overall animation.  Probably a good thing 
though.

___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


[iPhone] customizing UIView animation run background color

2009-11-17 Thread Tharindu Madushanka
Hi

I am using following method to flip between UIViews that have imageviews on
it as background. When I animate the views. I could see white background
color at animating time. Can I change this color. What I currently do is
like this.

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIAnimationCurveEaseInOut];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.view cache:YES];
[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:2];
[UIView commitAnimations];

while at animation time white background color is there. Could I change this
?

Thank you

-Tharindu
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] customizing UIView animation run background color

2009-11-17 Thread Luke the Hiesterman

self.view.backgroundColor = [UIColor blueColor]; //cause why not blue?

Luke

On Nov 17, 2009, at 7:32 AM, Tharindu Madushanka wrote:


Hi

I am using following method to flip between UIViews that have  
imageviews on
it as background. When I animate the views. I could see white  
background
color at animating time. Can I change this color. What I currently  
do is

like this.

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIAnimationCurveEaseInOut];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.view cache:YES];
[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:2];
[UIView commitAnimations];

while at animation time white background color is there. Could I  
change this

?

Thank you

-Tharindu
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com

This email sent to luket...@apple.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] customizing UIView animation run background color

2009-11-17 Thread Tharindu Madushanka
before animation I have set the background color but it did not work. Still
it was white even I set it to black. it seems like color is not coming from
self.view ??
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] customizing UIView animation run background color

2009-11-17 Thread Tharindu Madushanka
This is the method I use to switch views. And my views are created with
Interface Builder

- (IBAction)switchViews {
   self.view.backgroundColor = [UIColor blackColor];
   [UIView beginAnimations:nil context:nil];
   [UIView setAnimationDuration:1.25];
   [UIView setAnimationCurve:
   UIAnimationCurveEaseInOut];

   [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.view cache:YES];
   [self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:2];
   [UIView commitAnimations];
}

I cannot guess why its white bacground when animation runs :( Could any one
guess why is it ?

Thank you.
-Tharindu
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] customizing UIView animation run background color

2009-11-17 Thread Tharindu Madushanka
ah Thanks :) self.view.window.backgroundColor worked but I did not try
superview thing. Thank you

-Tharindu
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation docs question

2009-11-04 Thread Fritz Anderson


On 3 Nov 2009, at 4:23 PM, lorenzo7...@gmail.com wrote:

[UIView setAnimationDidStopSelector:@selector 
(animationDidStop:finshed:context:)];



-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *) 
finished context:(void *)context{...}


May I point out the spelling of the second part of the selector? In  
the method, it's fin_i_shed; in the argument, it's fin__shed.


— F

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation docs question

2009-11-04 Thread Matt Neuburg
On Wed, 4 Nov 2009 09:17:30 -0600, Fritz Anderson fri...@manoverboard.org
said:

On 3 Nov 2009, at 4:23 PM, lorenzo7...@gmail.com wrote:

 [UIView setAnimationDidStopSelector:@selector
 (animationDidStop:finshed:context:)];


 -(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)
 finished context:(void *)context{...}

May I point out the spelling of the second part of the selector? In
the method, it's fin_i_shed; in the argument, it's fin__shed.

Yeah, he knows.

This is the whole problem with passing things around as strings (selector
names, key-value coding, etc.); there are so many places to go wrong, and
when you do, it can be hard to debug. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation docs question

2009-11-03 Thread Klaus Backert


On 3 Nov 2009, at 23:23, lorenzo7...@gmail.com wrote:


Here's the code:

[UIView beginAnimations:@display context:NULL];
[UIView setAnimationDuration:0.30];
[UIView setAnimationDelegate:self];
[UIView  
setAnimationDidStopSelector 
:@selector(animationDidStop:finshed:context:)];


Really finshed -- the i missing -- above and finished below in  
your code?


-(void)animationDidStop:(NSString *)animationID finished:(NSNumber  
*)finished context:(void *)context{...}


Klaus

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


UIView animation docs question

2009-11-03 Thread lorenzo7620
The documentation for setAnimationDidStopSelector in the XCode 3.2.1: says  
this:


...The message sent to the animation delegate after animations end. The  
default value is NULL. The selector should be of the form: -  
(void)animationDidStop:(NSString *)animationID finished:(NSNumber  
*)finished context:(void *)context. Your method must take the following  
arguments:...


I created a method using this signature, but it was never called. I looked  
through some sample code from Apple and found at least one example that  
actually uses its own user defined selector that takes no arguments.  
Mimicking that, I created my own selector and that actually gets called. So  
my question is two fold:


1) Is this a bug in the documentation?
2) If I want the data that should be passed to the selector, how do I go  
about it?


Thanks
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Re: UIView animation docs question

2009-11-03 Thread lorenzo7620

On Nov 3, 2009 5:08pm, Klaus Backert klaus.back...@t-online.de wrote:



On 3 Nov 2009, at 23:23, lorenzo7...@gmail.com wrote:






Here's the code:





[UIView beginAnimations:@display context:NULL];



[UIView setAnimationDuration:0.30];



[UIView setAnimationDelegate:self];


[UIView  
setAnimationDidStopSelector:@selector(animationDidStop:finshed:context:)];





Really finshed -- the i missing -- above and finished below in your  
code?





-(void)animationDidStop:(NSString *)animationID finished:(NSNumber  
*)finished context:(void *)context{...}






Klaus




Silly mistake, sorry for the noise.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Re: UIView animation docs question

2009-11-03 Thread lorenzo7620

On Nov 3, 2009 3:44pm, Fritz Anderson fri...@manoverboard.org wrote:

On 3 Nov 2009, at 3:29 PM, lorenzo7...@gmail.com wrote:





The documentation for setAnimationDidStopSelector in the XCode 3.2.1:  
says this:




...The message sent to the animation delegate after animations end. The  
default value is NULL. The selector should be of the form: -  
(void)animationDidStop:(NSString *)animationID finished:(NSNumber  
*)finished context:(void *)context. Your method must take the following  
arguments:...




I created a method using this signature, but it was never called. I  
looked through some sample code from Apple and found at least one example  
that actually uses its own user defined selector that takes no arguments.  
Mimicking that, I created my own selector and that actually gets called.  
So my question is two fold:





1) Is this a bug in the documentation?


2) If I want the data that should be passed to the selector, how do I go  
about it?





Paste your code in which you set the delegate and the longer selector you  
want; also the callback you wanted Core Animation to use (you can omit  
the body of the method).





— F





Here's the code:

[UIView beginAnimations:@display context:NULL];
[UIView setAnimationDuration:0.30];
[UIView setAnimationDelegate:self];
[UIView  
setAnimationDidStopSelector:@selector(animationDidStop:finshed:context:)];



-(void)animationDidStop:(NSString *)animationID finished:(NSNumber  
*)finished context:(void *)context{...}


Thanks
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: UIView animation docs question

2009-11-03 Thread Fritz Anderson

On 3 Nov 2009, at 3:29 PM, lorenzo7...@gmail.com wrote:

The documentation for setAnimationDidStopSelector in the XCode  
3.2.1: says this:


...The message sent to the animation delegate after animations end.  
The default value is NULL. The selector should be of the form: -  
(void)animationDidStop:(NSString *)animationID finished:(NSNumber *) 
finished context:(void *)context. Your method must take the  
following arguments:...


I created a method using this signature, but it was never called. I  
looked through some sample code from Apple and found at least one  
example that actually uses its own user defined selector that takes  
no arguments. Mimicking that, I created my own selector and that  
actually gets called. So my question is two fold:


1) Is this a bug in the documentation?
2) If I want the data that should be passed to the selector, how do  
I go about it?


Paste your code in which you set the delegate and the longer selector  
you want; also the callback you wanted Core Animation to use (you can  
omit the body of the method).


— F

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


UIView animation

2008-04-06 Thread Benjamin BERTRAND

Hi,

I'm new to cocoa and have started to develop a board game for the  
iPhone.

I've been looking at the ColorSlidingPuzzle example provided by Apple.
I managed to animate a piece move using the function:
- (void) movePiece:(Move*) move {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.50];

// Change the position of my piece (an UIImageView)

[UIView commitAnimations];
}

Now here is my problem. I have an array with several moves that I want  
to display.
Doing a for loop obviously doesn't work. Only the last move is  
displayed (because nothing is updated until returning to the run loop  
I guess)...

for(Move *move in moveArray)
[self movePiece:move];

How can I display this succession of moves?

Thanks

Benjamin
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]