Standard way to have a UIBarButtonItem point to the right? - iphone

When a new view controller is pushed onto the navigation stack, there is standard support for a back button with the title of the previous view controller. This button "points" to the left rather than having a rounded rectanglar shape.
Is there a standard way to create a UIBarButtonItem that "points" to the right? This button would be used as the rightBarButtonItem.

Using the Three20 library you can do it easily without creating an image yourself (and it will size up correctly depending on your text):
This screenshot comes from the example application that comes with Three20.

You could use one of the PNG files floating around with iPhone UI widgets (example). Take the left-pointing button and flip it horizontally in Photoshop or another image editing tool to make it point right-wards.
Then insert a UIButton into the rightBarButtonItem view, using the horizontally-flipped widget as its image property.

Related

Adding a UIToolBar above a UITabBar - Logic Issue

I need to know the logic of how to write this code.
This is my problem.
When a user taps a button, I need to show a UIToolBar (with a few buttons on it) on the view. This toolBar should appear ONLY above the UITabBarcontroller.
The view is a UIScrollView, so if I hardcode the position of the UIToolBar, it will be displayed in the wrong position each time the user scrolls (Hope you understand what I am saying).
I did the following. I hard coded the position of the UIToolBar (so it will place above the tab bar), and added it to the Window. This sounds like a good solution as the windows size will not change at all instance.
But, I don't want to add this to a Window. So is there any other way I could solve this problem?
I would add an additional UIView to the window so that it acts as a container for both the UIScrollView and UIToolbar. Then resize the scrollview so that it falls short of the toolbar.
You should be thinking of this as layers of views

iPhone Fall Down button (Animation)

Is it possible do something like this ?
When I click on the button I need the following animation: button to set some alpha filter and starts to fall down as indicated by the arrow, it will disappear on tab.
Can you tell me how to do this ? Thanks a lot ...
Here is image url: http://img534.imageshack.us/img534/8149/screenqx.jpg
It's definitely possible, but there are some issues you have to overcome. One is that UIBarButtonItem isn't a UIView. One way is to loop through the subviews of the UIToolbar or UINavigationBar. Another way is to figure out the position of the button. Another is to get the view using private api if you're not submitting to the AppStore.
Once you have the view, you can move it to the superview of the UIToolbar or UINavigationBar or you can create a view on top of that (and hide the real UIBarButtonItem since you're done with that). The latter is more difficult because mimicking the look of the default bordered UIBarButtonItem isn't easy.
Now you need to get the center of the UITabBarItem somehow. You can either use private api or you can loop through the subviews.
Create a CGPath using Quartz functions or using UIBezierPath. The start point will be the center of the button and the end point will be the center of the UITabBarItem.
Create a CAKeyFrameAnimation and attach said CGPath.
Create a CABasicAnimation to animate the opacity.
Add both to a CAAnimationGroup.
Attach the animation group to your button view's CALayer.
Make sure to also set the position and the alpha in order to prevent the view from jumping back to its original position after the animation.
Once you attach the animation group, the animation should start, so make sure you're doing all of this in the button's selector method.
You can't really move it from view to view, as your views could clip and then you'd get frames with only a partial image. Probably the best thing to do is to create a view on the fly which covers the whole screen, copy the button image into the view at the original point, remove the button from the original view, then animate that image to where you want it to go, then add the button to the final destination.

Display 2 images at the same time in UIScrollView

I'm quite new to iPhone development, and now dealing with a remote control app. Currently I can receive desktop image and perform simple mouse operations. But I still want to show a mouse pointer on my iPhone screen.
The desktop (very big, 1280X800) is in a image view which is the subview of a scroll view. Is there any way I can add a pointer image on top of the desktop image, and set it to any place I want? The pointer image do not receive any user interaction, it would be just floating on the desktop image.
Thank you very much for help.
Yes, just create a new UIImageView (or any other UIView subclass) with a frame based on where you want it to appear and add it to the scroll view's view using the addSubview: method. By default subviews you add later will appear above subviews you add earlier, but you can explicitly control which view appears on 'top' using 'bringSubviewToFront:'.

UIBarButtonItem Taking Entire Width of UIToolbar

I have a UIToolbar with a UIBarButtonItem that I created in Interface Builder. The UIBarButtonItem is a bordered button that contains a custom image.
The button takes up the entire length of the toolbar. I have tried using different images, changing the width of the button... I don't know what else to do. It stretches across the entire toolbar.
If I use one the provided "Identifiers" (camera, trash, compose...) the button appears a normal size.
How it looks in Interface Builder
How it looks when I run it on the iPhone
SOLUTION
After some more tinkering, here is what I found: if I create a new UIToolbar and add custom image to the UIBarButtonItem, it works fine - but as soon as I connect the UIBarButtonItem to an IBOutlet, it goes large. I had to then specify the UIBarButtonItem's width in the code, via the IBOutlet.
Try adding a UIBarButtonSystemItemFlexibleSpace on the right of the camera bordered item.
I'm not an expert, but I think it might have to do with how the frame is defined in the "sizing inspector", could you maybe show a screenshot of the settings?

UIBarButtonItem in middle of navbar?

I have created a flexible navigation bar in my app that will show custom buttons on the left, right, and in the middle. So far I have got working:
Right/Left/Middle - Custom Image and/or Text
Right/Left - Normal looking button with custom Image in it
Right/Left - Normal looking button with custom Text in it
By 'normal looking' I mean the default UIBarButtonItemStyle- just a nice shiny button.
My question is, how can I achieve the same look in the MIDDLE of the nav bar? I can do custom/text images by just creating a custom UIButton, and on the right / left I create a UIBarButtonItem from it, but in the middle I just add the UIButton view as a subview of the navbar.
I can't add a UIBarButtonItem to the navbar as a subview, and any UIButton I create doesn't look like a UIBarButtonItem.
The only workaround I can think of is to use a stretchable custom image that I steal from a screenshot. I'd rather avoid doing it this way. Am I missing something?
*********** UPDATE **************
The open source library Three20 will allow you to create UIButtons that look like UIBarButtonItems. Then you can add them to the bar view either by placing manually as a subview or by setting the title view.
I never understood why they didn't make UIBarButtonItems derive from UIViews (or even better, UIButtons) so they could be used elsewhere.
Sounds like you're on the right track, but need better artwork :-) You can get a large number of iPhone UI components in a Photoshop .PSD file from here. They have pre-rendered bar buttons which you can use as a base for a standard UIButton image. If you have Photoshop (or a decent drawing program) you can stretch the buttons from the middle to fit your size without getting the corners distorted. Just add the label and you should be good to go.
Put a flexible region on the left and right, they will offset each other causing anything between them to be centered