HomeiOS DevelopmentHow to attract a curve like this in Swift iOS?

How to attract a curve like this in Swift iOS?


I’ve a really primary data of UIBezierPath() and Curve-related views. I’ve a customized class for this as I’ve a typical footer view throughout the entire app.

That is what I would like: My anticipated end result

That is what I’ve achieved: enter picture description right here

Beneath is my code:

import UIKit

class FooterView: UIView {

@IBOutlet weak var footerImageView: UIImageView!

override func draw(_ rect: CGRect) {
let path = UIBezierPath()
let fillColor = UIColor.blue

let y: CGFloat = rect.dimension.top
let x: CGFloat = rect.dimension.width
let top: CGFloat = rect.top

path.transfer(to: CGPoint(x: 0, y: top)) // high left
path.addLine(to: CGPoint(x: x, y: top)) // high proper
path.addCurve(to: CGPoint(x: 0, y: 0), controlPoint1: CGPoint(x: x / 2, y: 0), controlPoint2: CGPoint(x: x / 2, y: top)) // curve to backside left
path.shut() // shut the trail from backside left to high left

fillColor.setFill()
path.fill()
}


override init(body: CGRect) {
tremendous.init(body: body)
self.backgroundColor = .crimson
}

required init?(coder aDecoder: NSCoder) {
tremendous.init(coder: aDecoder)
self.backgroundColor = .yellow
}

non-public func commonInit(){

Bundle.foremost.loadNibNamed("FooterView", proprietor: self, choices: nil)
// footerImageView.contentMode = .scaleAspectFill
// addSubview(footerImageView)
}

}

It will be nice if somebody may assist me!
Thank You!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments