logo
down
shadow

Subclass of UIButton with rounded corners (swift)


Subclass of UIButton with rounded corners (swift)

By : Mac Chavez
Date : November 22 2020, 09:00 AM
hope this fix your issue You need to use clipsToBounds to ensure that the containing view isn't drawn over the corner radius:
code :
self.clipsToBounds = true


Share : facebook icon twitter icon
Custom UIButton rounded corners

Custom UIButton rounded corners


By : user3717394
Date : March 29 2020, 07:55 AM
I hope this helps . Create your custom buttons as normal UIButtons, with your custom image. Then create UIBarButtonItems with your new UIButton as a custom view (you can see how to do this in the UIBarButtonItem class reference).
Then, set your view controller's navigationItem to have your new UIBarButtonItems as the leftButtonItem, rightButtonItem and so on.
UIButton: why are rounded corners visible?

UIButton: why are rounded corners visible?


By : Dermot McGuire
Date : March 29 2020, 07:55 AM
may help you . for all your answers, I'm sure your suggestions are working in 99,99% of all cases. But in my special case it seems that xCode was messing things up completely.
I restarted xCode several times, double checked all settings (e.g. outlets) in IB and in code. I cleaned the project. I removed the app from the iPad and reinstalled it. I even created some new buttons in the xib, which all had the same problem.
UIButton with rounded corners allows interaction in the corners

UIButton with rounded corners allows interaction in the corners


By : Olga
Date : March 29 2020, 07:55 AM
should help you out you can subclass the UIButton;
in – (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event check if touch point is inside the area we are interested in, otherwise return nil. More about this here: http://www.planet1107.net/blog/custom-shape-uibutton-tutorial/
iOS UIButton with rounded corners and background bug

iOS UIButton with rounded corners and background bug


By : RemiNoel
Date : March 29 2020, 07:55 AM
seems to work fine I found one weird issue with rounded UIButton. , Use CAShapeLayer instead, it also gives enhanced performance:
code :
    let roundedButton = UIButton(type: .Custom)
    roundedButton.frame = CGRectMake(100, 100, 100, 100)
    let _border = CAShapeLayer()
    _border.path = UIBezierPath(roundedRect: roundedButton.bounds, cornerRadius:roundedButton.frame.size.width/2).CGPath
    _border.frame = roundedButton.bounds
    _border.strokeColor = UIColor.whiteColor().CGColor
    _border.fillColor = UIColor.blackColor().CGColor
    _border.lineWidth = 3.0
    roundedButton.layer.addSublayer(_border)

    self.view.addSubview(roundedButton)
Adding shadow layer with rounded corners on custom UIButton subclass

Adding shadow layer with rounded corners on custom UIButton subclass


By : user1925089
Date : March 29 2020, 07:55 AM
this will help I'm trying to apply a shadow and rounded corners on custom UIButton subclass to use in on the storyboard , Try also setting the .cornerRadius on the gradient layer:
code :
    gradientLayer.endPoint = CGPoint(x: 0.75, y: 0.5)

    // add this line        
    gradientLayer.cornerRadius = 8

    layer.insertSublayer(gradientLayer, at: 0)
Related Posts Related Posts :
  • How to call/get date and time from a website in swift
  • rxswift error handle issue
  • Cannot stream video with swift 2 AVPlayerViewController
  • PFFile as UIImageView
  • Sort dictionary keys by value, then by key
  • What's going on with this generic function?
  • How to implement a failable initializer for a class conforming to NSCoding protocol in Swift?
  • Swift: optional or implicit UILabel?
  • Swift: ¨Unrecognized selector sent to instance¨
  • Initialize a dictionary with non-optional empty arrays in Swift
  • Compare Day/Month in Swift Struct
  • swift reflection causes impossible nil value for any
  • Equatable in Swift
  • How to populate an SKShapeNode uniformly
  • Using AWS API Gateway generated SDK for both authenticated and anonymous access
  • Underscored properties in Swift classes?
  • Google API Maps don't show up on TabBar Application
  • Can't hide status bar in AVPlayerViewController's portrait mode
  • Send JSON Array and store in database using api calls
  • Return one of two possible classes instances
  • What is type of 123_456_789?
  • dispatch queue concurrent not work as except in swift
  • Calculate count of years
  • Swift property observer in protocol extension?
  • Calling function with optional type in Swift
  • in Swift, what does this specific syntax mean?
  • Nil cannot be assigned to type AVCaptureDeviceInput
  • Parse - Query with 'includeKey' not getting objects in proper subclass
  • Best way to set up multiple tableviewcell layouts
  • Swift Bridging Header for Obj-C
  • Swift dictionary with weak reference keys?
  • Commit failed - the repository is locked, XCode 7
  • How to convert Swift Bool? -> String?
  • Swift: Cannot convert value of type 'NSDate' to expected argument type 'NSDateComponents'
  • JSON parsing error in Swift 2.0
  • Varying value inside runAction() not changing
  • Swift - bar button item image / set size and width
  • Radio button UI in Swift
  • NSdate range total removing weekends Swift
  • Why isn't addTarget calling my target's action in an extension
  • How to make a cell hold multiple text labels in ios
  • Setter for dictionary property - OR: get last added item from dictionary
  • Extending Dictionary with constraints
  • Spritekit rotating multiple nodes around center
  • Swift: Trying to implement NSCoding
  • Array of String printing Optional, why?
  • Dynamic attributes (getters/setters) in Swift on data models
  • Setting file attributes in Swift
  • Window visible on all spaces (including other fullscreen apps)
  • How to draw lines on UIImage with swift ?
  • Is it possible use non read-only computed property in extension?
  • How do I save a MKPointAnnotation to Pars?
  • Take a snapshot of current screen with Metal in swift
  • Is there any way to determine sub-protocol conformance for instance conforming to generic protocol in Swift 2 (at runtim
  • Custom physics body adding unwanted extra line
  • Define a Swift protocol which requires a specific type of sequence
  • Swift tvOS in-app purchase doesn't respond
  • Swift calculate incremental average with reduce and
  • push from custom cell nib to viewController
  • Detect when a tab bar item is pressed
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co