cornerradius

Swift - Problems with corner radius and drop shadow

拥有回忆 提交于 2019-11-26 15:03:40
问题 I'm trying to create a button with rounded corners and a drop shadow . No matter how I switch up, the button will not display correctly. I've tried masksToBounds = false and masksToBounds = true , but either the corner radius works and the shadow does not or the shadow works and the corner radius doesn't clip the corners of the button. import UIKit import QuartzCore @IBDesignable class Button : UIButton { @IBInspectable var masksToBounds: Bool = false {didSet{updateLayerProperties()}}

UIView animateWithDuration doesn't animate cornerRadius variation

人走茶凉 提交于 2019-11-26 12:38:56
问题 I\'m trying to animate the change of the cornerRadius of a UIView instance layer , but the variation of the cornerRadius takes place immediately. Here\'s the code: UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)]; view.layer.masksToBounds = YES; view.layer.cornerRadius = 10.0; [UIView animateWithDuration:1.0 animations:^{ [view.layer.cornerRadius = 0.0; }]; Thanks everybody who is going to give me any tips. EDIT: I managed to animate this property using Core

How to set cornerRadius for only top-left and top-right corner of a UIView?

感情迁移 提交于 2019-11-25 22:48:18
问题 Is there a way to set cornerRadius for only top-left and top-right corner of a UIView ? I tried the following, but it end up not seeing the view anymore. UIView *view = [[UIView alloc] initWithFrame:frame]; CALayer *layer = [CALayer layer]; UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRoundedRect:frame byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight) cornerRadii:CGSizeMake(3.0, 3.0)]; layer.shadowPath = shadowPath.CGPath; view.layer.mask = layer; 回答1: Swift 4 Pay