Get rid of rounded corners of Round Rect Button (MonoTouch) - iphone

I want to get rid of the rounded corners of a UIButton (type = Round Rect Button). I want to stack some buttons to give a UITableView look and want to get rid of the rounded corners in some instances. Is this possible? (MonoTouch)

If th type is rounded rect, it has the rouded corner. Use a custom type to do exactly what you want.
If you're in interface builder, just select custom type, you can then use a background image or normal layer attributes (border, shadow...).
In code, don't create a new classe, jsut create a button and set the type to custom.

Create the image of the button you want (in Photoshop, or whatever else floats your boat), change the button type to "Custom" and then import the created image to your project and set it under the "Image:" drop down in Interface Builder.
Tada, customization complete.

Have a look at UIButtonType to see all the types of button you can create (including a custom one). E.g.
var b = new UIButton ();
b.ButtonType = UIButtonType.Custom;
OTOH if you want to do things that looks like UITableView then I strongly suggest you to look at MonoTouch.Dialog and its sample application - which includes ownerdraw elements. It will be as easy (or easier) than dealing with several buttons (and much easier than using UITableView).

Related

Any way to adjust a button built with interface builder to reverse when tapped?

I am not a huge fan of interface builder but I am trying to create a UIButton that would highlight when touched. I was thinking the whole button to reverse. I see this property reverses on highlight but what it does is to reverse the text. I want the whole button to reverse color.
This is how I have it now:
This is a green button with rounded corners. Is there a way to make the whole button to reverse from interface builder?
This is an iOS 7 only project.
If you want to keep things inside interface builder, I believe your only option is to configure different background images for each button state. I had the same problem and couldn't find a way to use different UIColors for different button states. If your button style is really minimal, you could potentially use 1x1 pngs and apply rounded corners using Quartz directly in code.
In my case, I ended up creating a custom subclass of UIButton with a setter to configure different colors/text colors and shadows for each state (I used an enum to map different button "themes").

How to design rounded boxes and separators (like the App Settings view)?

I am wondering what is the good way to design interfaces such as the one in the Settings view on an application, for instance :
What I want to do is the nice round rectangle to separate categories and horizontal line separators between categories, I can have a label, text field, slider or any other control in each line...
Do we need to use an image in the background, that seems quite dirty to me, and I cant find any control in IB that seem to do the same kind of layout.
So, how is this done?
Thanks!
Use a UITableView and set it's style to UITableViewStyleGrouped. Remember that the standard UITableViewCell's will just let you show some text and you may need to create custom UITableViewCell's to achieve more (for example, a on-off switch).
If you wan't to customise it you can add a background image. To do this, place a UIImageView behind the UITableView and make sure you set the UITableView background colour to clear:
theTableView.backgroundColor = [UIColor clearColor];
To seperate the categories make use of the "sections".
Basically, you can use grouped table.You can have sections with different/same number of rows.

Custom UIToolBar from Images

I need to create a UIToolbar object that uses an image for the background. Most of the buttons are images as well, and rectangular. One button, however, is round and overlaps the toolbar like the Start button on the Windows task bar. See below.
I know that I will need to subclass the UIToolbar to paint the image for the toolbar -- I think. If so, does anyone have example code showing how to do this?
Furthermore, does anyone have any ideas on how to implement the larger round button? I'm thinking of another custom subclass for this, but not sure if there might be an easier way.
I can have the art guys chop the image anyway needed, which I'm sure the round button will need to be chopped some how.
Any ideas or sample code?
alt text http://iphone.sophtware.com/toolbar.png
Maybe you'll find some inspiration at this tutorial : Recreating The Raised Center Tab Bar Button of Instagram, DailyBooth & Path
For the color, you can experiment with the tintColor property.
As for the rest, UIToolbar is not designed for this. You will need a custom component (probably based on UIView).
I think it is possible but hard.
Override the drawRect method of the toolbar to draw the whole image. Then add left and right buttons.
For the round button you can add one invisible button on the bottom middle of the View and another invisible button in the middle of toolbar. Of course, you can try to use the views instead of the buttons and track the user interaction manually.

iPhone: how to reduce UIBarButtonItemWidth?

I've created a UIBarButtonItem and then set self.navigationItem.rightBarButtonItem to the item.
However, setting the width property of the barButtonItem doesn't seem to have any effect on the width of the button (I'm trying to reduce the width of the barButton)
If I use a custom view for the UIBarButtonItem, I'm able to set the width of the view (and that in turn sets the width of the barButton)
However, I want to get the look and feel of the standard UIBarButtonItem.
Does anyone know how to reduce the width of the UIBarButtonItem without using a custom view ?
(alternately, does anyone know how to create a UIView or UIButton that looks like a UIBarButtonItem)
Looks like Apple really don't want it (Human Interface Guidelines). However there is a somewhat static solution if you use your own view for it:
Just use images instead... use grab to copy the images from IB at the widths you want.
Then they'll look exactly like the UIBarButtons
Apple shows you how to map two different images (and in this example functions as well) to the same button depending on the state... check out the "Add Music" sample code: http://developer.apple.com/iphone/library/samplecode/AddMusic/index.html
This is from TechGuru # http://discussions.apple.com/thread.jspa?messageID=9822548

iPhone dev: adding an overlapping label to the image

I'm trying to figure out a best way to implement the picture-editing capability shown in the native address book app on iPhone.
On the built-in address book, this is how the picture looks like before editing:
qkpic.com/2f7d4 http://qkpic.com/2f7d4
And after clicking edit, notice how "Edit" overlay is added and the image becomes clickable:
qkpic.com/fb2f4 http://qkpic.com/fb2f4
What would be the best way to implement something like this? Should I make the image a button from the beginning and have tapping disabled at first? If so, what steps are required to add an overlay/label to the image (in above example, gray border + the text "Edit" is added)
The easiest way is to use Interface Builder, create a container view, then add a UIImageView and UILabel as subviews to it. You would position and style the text and the image but set the UILabel to hidden. Make the whole container view respond to touches. It's easy to do since UIView is derived from UIResponder so all you have to do is override touchesEnded. Whenever you want to change the text label, just set the UILabel to hidden=NO.
There's more to it, however. Notice how the image has rounded corners? You'll want to override the UIImageView's drawRect method to implement a custom drawing routine to do that. There's lots of sample code around and it wasn't part of your original question so I'll stop here.