728x90
//
// ViewController.swift
// Practice
//
//
import UIKit
class ViewController: ViewController {
override func viewDidLoad() {
super.viewDidLoad()
//배경 구분
view.backgroundColor = UIColor.lightGray
//원형 밑그림
let circlePath = UIBezierPath(arcCenter: view.center, radius: 150, startAngle: 0, endAngle: .pi * 2, clockwise: true)
circlePath.close()
//track 형태
let trackLayer = CAShapeLayer()
trackLayer.path = circlePath.cgPath
trackLayer.lineWidth = 15
trackLayer.fillColor = UIColor.clear.cgColor
trackLayer.strokeColor = UIColor.gray.cgColor
view.layer.addSublayer(trackLayer)
//progress
let progressLayer = CAShapeLayer()
progressLayer.path = circlePath.cgPath
progressLayer.fillColor = UIColor.clear.cgColor
progressLayer.lineWidth = 15
progressLayer.lineCap = .round //progress line stroke 끝을 둥글게
progressLayer.strokeColor = UIColor.green.cgColor
progressLayer.strokeStart = 0
progressLayer.strokeEnd = 0.75 //75%
view.layer.addSublayer(progressLayer)
}
}
728x90
'iOS > 예제' 카테고리의 다른 글
[iOS 예제] CircleProgressView 만들기 (0) | 2021.12.11 |
---|---|
[iOS 예제] UIView에 원형으로 shadow 넣기 (0) | 2021.12.07 |
[iOS 예제] Drag and Drop가능한 UIView만들기 (0) | 2021.12.05 |
[iOS 예제] InfiniteTextView 무한 스크롤 텍스트뷰 만들기 (0) | 2021.06.17 |
[iOS 예제] UIPanGestureRecognizer로 BottomSheet 만들어보기 (0) | 2021.05.01 |
댓글