How can I do programmatically gradient border color UIButton with Swift [closed]

let gradient = CAGradientLayer() gradient.frame = CGRect(origin: CGPointZero, size: self.myButton.frame.size) gradient.colors = [UIColor.blueColor().CGColor, UIColor.greenColor().CGColor] let shape = CAShapeLayer() shape.lineWidth = 2 shape.path = UIBezierPath(rect: self.myButton.bounds).CGPath shape.strokeColor = UIColor.blackColor().CGColor shape.fillColor = UIColor.clearColor().CGColor gradient.mask = shape self.myButton.layer.addSublayer(gradient) Swift 3 version: let gradient = CAGradientLayer() gradient.frame = CGRect(origin: CGPoint.zero, size: self.myButton.frame.size) gradient.colors = [UIColor.blue.cgColor, UIColor.green.cgColor] let shape = … 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)

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 to get click event from a button added over MKAnnotationView

The standard UI approach is to use the callout view and add an accessory button as progrmr shows. However, if you must add a button directly to the MKAnnotationView, the problems with your approach are that the MKPinAnnotationView‘s default frame (which can’t easily be changed) is smaller than the button you’re adding so most of … Read more

Multiline UIButton and autolayout

I had the same problem where I wanted my button to grow along with its title. I had to sublcass the UIButton and its intrinsicContentSize so that it returns the intrinsic size of the label. – (CGSize)intrinsicContentSize { return self.titleLabel.intrinsicContentSize; } Since the UILabel is multiline, its intrinsicContentSize is unknown and you have to set … Read more

Make custom button on Tab Bar rounded

Solution You need to subclass UITabBarController and then add the button above TabBar‘s view. A button action should trigger UITabBarController tab change by setting selectedIndex. Code The code below only is a simple approach, however for a full supporting iPhone (including X-Series)/iPad version you can check the full repository here: EBRoundedTabBarController class CustomTabBarController: UITabBarController { … Read more

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