Programmatically create a UIView with color gradient

Objective-C: UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = view.bounds; gradient.colors = @[(id)[UIColor whiteColor].CGColor, (id)[UIColor blackColor].CGColor]; [view.layer insertSublayer:gradient atIndex:0]; Swift: let view = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 50)) let gradient = CAGradientLayer() gradient.frame = view.bounds gradient.colors = [UIColor.white.cgColor, UIColor.black.cgColor] view.layer.insertSublayer(gradient, at: 0) Info: … Read more

UIView with rounded corners and drop shadow?

Swift // corner radius blueView.layer.cornerRadius = 10 // border blueView.layer.borderWidth = 1.0 blueView.layer.borderColor = UIColor.black.cgColor // shadow blueView.layer.shadowColor = UIColor.black.cgColor blueView.layer.shadowOffset = CGSize(width: 3, height: 3) blueView.layer.shadowOpacity = 0.7 blueView.layer.shadowRadius = 4.0 Exploring the options Problem 1: Shadow gets clipped off What if there are sublayers or subviews (like an image) whose content we want … Read more

How to add constraints programmatically using Swift

Do you plan to have a squared UIView of width: 100 and Height: 100 centered inside the UIView of an UIViewController? If so, you may try one of the 6 following Auto Layout styles (Swift 5 / iOS 12.2): 1. Using NSLayoutConstraint initializer override func viewDidLoad() { let newView = UIView() newView.backgroundColor = UIColor.red view.addSubview(newView) … Read more

Giving UIView rounded corners

Try this #import <QuartzCore/QuartzCore.h> // not necessary for 10 years now 🙂 … view.layer.cornerRadius = 5; view.layer.masksToBounds = true; Note: If you are trying to apply rounded corners to a UIViewController‘s view, it should not be applied in the view controller’s constructor, but rather in -viewDidLoad, after view is actually instantiated.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)