Re: any way to know where a UIBarButtonItem has been drawn?
Re: any way to know where a UIBarButtonItem has been drawn?
- Subject: Re: any way to know where a UIBarButtonItem has been drawn?
- From: Jamie Pinkham <email@hidden>
- Date: Mon, 12 Sep 2011 14:47:15 -0400
If your use case permits, you can figure out the frame of the bar button item in it's action selector by giving the selector the following signature:
- (void)barButtonAction:(UIBarButtonItem *)item event:(UIEvent *)event;
You can then use the properties of UIEvent to get the touches location, or the view that the touches belong to.
For instance:
- (IBAction)barButtonAction:(UIBarButtonItem *)sender event:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
CGPoint locationInView = [[[event allTouches] anyObject] locationInView:self.view];
NSLog(@"event touch location = %@", [NSValue valueWithCGPoint:locationInView]);
NSLog(@"touch.view = %@", [touch view]);
}
On Sep 12, 2011, at 12:53 PM, Roland King wrote:
> I have a toolbar with items on it. One of them is a trash can. When I delete something from the main screen I'd like it to 'minify' towards the trash can, well I think I would, I have to see what it looks like and see if the effect is as nice as I hope, I want to draw attention to where the 'thing' has gone and this seems like a reasonable animation to try.
>
> However .. I can't figure out what the frame for the UIBarButtonItem is .. it's on a bar with items which change, some flexible space etc, so it's not a fixed offset from either end of the the thing, and I can't find an API which tells me what the frame is for a given item. Is there one I've missed? _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden