Tag: uibutton

Drawing backgroundcolor & border Vs Background PNGs

I want specific RGB hex color for most of the buttons for my iPad Application. What I have done is: I have implemented UIButton Subclass in my project which emulates the required background color, text color & border for buttons – and then I use it everywhere in my project where I need UIButton. My […]

UIButtons titleLabel clips Text after being rotated by CGAffineTransformMakeRotate()

I am developing a iOS-6 app. I have a UIViewController with a view that needs fixed orientation (portrait mode). But when the phone is rotated, one control on that view needs to be moved and rotated (so that it will always be in the upper left corner, and its text will be readable). I am […]

Why is there a rough black edge when rounding corner of UIButton?

I’m adding a UIButton (with background image) to the navigation bar and setting rounded corners with a border. I’m getting a strange black outline on the corners: Here’s the code I’m using to create the button from viewDidLoad: ProfileImageService *profileImageService = [ProfileImageService getService]; CGRect frame = CGRectMake(0, 0, 32, 32); UIButton *button = [[UIButton alloc] […]

How to create and add UIButton with multiline label from code using autolayout?

There’s are a lot of links how to size a label, however there’s a lack of info how to resize UIButton according to its label size. Currently, I have screen view set with autolayout (all the system constraints are added from IB) and everything works fine, but need to add dynamic content at the bottom […]

If this is the right way to use a customised string property in Objective C, why can’t I extract the correct numeric value?

I am revising an early project where I use tags to identify 1-of-5, 1-of-16 or 1-of-10 UIButtons. I want to replace the tags with a customised property based on my understanding of this answer. The property called myInfo consists of a string followed by an integer. This may well be a tag by another name […]

Can't add target for UIButton – unrecognised selector sent to instance, despite method been in the very same class

I’ve got a UIButton in an Objective-C iOS Class, called StickerClass. The class has a public instance of a UIButton called ‘theView’. In the constructor of StickerClass, I set the initial properties such as frame, layer properties and subviews, and the target for when it’s clicked on, using: [theView addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchUpInside]; There’s a top […]

Add Selector to UIButton

I have ViewController and then two different ViewControllers that extend that main ViewController, one for the iPhone and the other for the iPad. The iPad’s ViewController instantiates a separate extended UIView and sets it as its own view. That view has some buttons, which I want to add its selector methods as some methods in […]

UIView animation change size of button

I started trying to recreate the buy button from the app store which requires a 2-stage click to buy something. I to animate the button expanding. So far I have this [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.75]; sender.autoresizesSubviews = NO; sender.clipsToBounds = NO; sender.frame = CGRectMake(63,326,200,37); [UIView commitAnimations]; which just causes the button to become larger, […]

How to expand the hitTest area of a UIButton without extruding it's background image?

I have set the UIButton‘s background image and put a title on it(I used setBackgroundImage method not setImage). Now I want to expand the hitTest area of a UIButton without extrude it’s background image. How can I do this?

Change UIButton type programmatically

I have an UIButton made with IB, it is set to “Rounded Rect”. At one point, I’d like to change the type to “Custom” in the code, is that possible ? I saw the type can be set at creation, but did not see if it was possible to change it later on.