UIScrollview with UIButtons – how to recreate springboard?

Solution that worked for me included: Setting canCancelContentTouches in UIScrollView to YES. Extending UIScrollView to override touchesShouldCancelInContentView:(UIView *)view to return YES when view is a UIButton. According to documentation touchesShouldCancelInContentView returns “YES to cancel further touch messages to view, NO to have view continue to receive those messages. The default returned value is YES if … Read more

Use table view disclosure indicator style for uibutton ios

This can be done entirely with code by placing a UITableViewCell with the disclosure indicator within a UIButton: UITableViewCell *disclosure = [[UITableViewCell alloc] init]; disclosure.frame = button.bounds; disclosure.accessoryType = UITableViewCellAccessoryDisclosureIndicator; disclosure.userInteractionEnabled = NO; [button addSubview:disclosure]; Swift: let disclosure = UITableViewCell() disclosure.frame = button.bounds disclosure.accessoryType = .disclosureIndicator disclosure.isUserInteractionEnabled = false button.addSubview(disclosure)

iOS – Delayed “Touch Down” event for UIButton in UITableViewCell

This is caused by the UIScrollView property delaysContentTouches. It used to be sufficient to just set that property to NO for the UITableView itself, but that will only work for subviews of the table that are not encased in another UIScrollView. UITableViewCells contain an internal scroll view in iOS 7 so you will need to … Read more

UIBarButtonItem with custom view not properly aligned on iOS 7 when used as left or right navigation bar items

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];

iOS 7 round framed button

You can manipulate the CALayer of your button to do this pretty easily. // assuming you have a UIButton or more generally a UIView called buyButton buyButton.layer.cornerRadius = 2; buyButton.layer.borderWidth = 1; buyButton.layer.borderColor = [UIColor blueColor].CGColor; // (note – may prefer to use the tintColor of the control) you can tweak each of those to … Read more

How to add 2 buttons into the UINavigationbar on the right side without IB?

With iOS 5+ it’s as easy as: UIBarButtonItem *btnShare = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)]; UIBarButtonItem *btnRefresh = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh)]; [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:btnShare, btnRefresh, nil]];

How can I init a UIButton subclass?

With Swift 3, according to your needs, you may choose one of the seven following code snippets to solve your problem. 1. Create your UIButton subclass with a custom initializer This solution allows you to create instances of your UIButton subclass with the appropriate value for your property. With this solution, you can only create … Read more

UITableViewCells with UIButton overlaps while scrolling

just replace the line UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier] is now UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil]; (or) //use this in cell for rowatindexpath for(UIView *view in cell.contentView.subviews){ if ([view isKindOfClass:[UIView class]]) { [view removeFromSuperview]; } }