UIButton title alignment and multiline support
Here’s the code to do the UIButton alignment in code too: – [myButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
Here’s the code to do the UIButton alignment in code too: – [myButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
You can use this code,it will serve your purpose .h file code IBOutlet UIButton *testBtn; .m file code [testBtn setImage: [UIImage imageNamed:@”Image name.png”] forState:UIControlStateNormal]; [testBtn setTitleEdgeInsets:UIEdgeInsetsMake(70.0, -150.0, 5.0, 5.0)]; [testBtn setTitle:@”Your text” forState:UIControlStateNormal]; Adjust the coordinates and size of your button as your requirement.This is a sample code to guide you. PS:Take a UIButton in … Read more
Apple says that the avg finger tap is 44×44 (from WWDC). All table rows are recommended to be at least that height. It is common for icons to appear 32×32, but have padding to make the touchable area 44×44. Of course, people can tap a 1×1 if they are very careful, but why make people … Read more
[*yourlabelname* setTransform:CGAffineTransformMakeRotation(-M_PI / 2)]; rotated image pervious image
titleEdgeInsets The inset or outset margins for the edges of the button title drawing rectangle. @property(nonatomic) UIEdgeInsets titleEdgeInsets Discussion Use this property to resize and reposition the effective drawing rectangle for the button title. You can specify a different value for each of the four insets (top, left, bottom, right). A positive value shrinks, or … Read more
I am putting my answer in a similar format to this answer. Here is the original label: Rotate 90 degrees clockwise: yourLabelName.transform = CGAffineTransform(rotationAngle: CGFloat.pi / 2) Rotate 180 degrees: yourLabelName.transform = CGAffineTransform(rotationAngle: CGFloat.pi) Rotate 90 degrees counterclockwise: yourLabelName.transform = CGAffineTransform(rotationAngle: -CGFloat.pi / 2) Do the same thing to rotate a button. Thankfully the touch … Read more
You can mix the cornerRadius and shadow properties. I tested it on iOS 8. Objective-C: [self.globeButton setImage:[UIImage imageNamed:@”Globe”] forState:UIControlStateNormal]; self.globeButton.backgroundColor = [UIColor colorWithRed:171 green:178 blue:186 alpha:1.0f]; // Shadow and Radius self.globeButton.layer.shadowColor = [[UIColor colorWithRed:0 green:0 blue:0 alpha:0.25f] CGColor]; self.globeButton.layer.shadowOffset = CGSizeMake(0, 2.0f); self.globeButton.layer.shadowOpacity = 1.0f; self.globeButton.layer.shadowRadius = 0.0f; self.globeButton.layer.masksToBounds = NO; self.globeButton.layer.cornerRadius = 4.0f; Swift: … Read more
I am using auto layout. Solution that worked for me was setting UIButton‘s contentEdgeInsets. ObjC button.contentEdgeInsets = UIEdgeInsetsMake(0.0f, 30.0f, 0.0f, 30.0f); Swift button.contentEdgeInsets = UIEdgeInsets(top: 0.0, left: 30.0, bottom: 0.0, right: 30.0)
You can also set the inset values from the Interface Builder Size Inspector inside a Storyboard or xib.
Works until iOS11! You can use negative flexible spaces and rightBarButtonItems property instead of rightBarButtonItem: UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; spacer.width = -10; // for example shift right bar button to the right self.navigationItem.rightBarButtonItems = @[spacer, yourBarButton];