UIGradient icon indicating copy to clipboard operation
UIGradient copied to clipboard

There are incorrect results if the frame of the view is large (Bug)

Open HassanTaleb90 opened this issue 1 year ago • 0 comments

If the frame of a view is large, for example: width = 3_000 and height = 3_000. The CPU runs >100% for a bit then drops to 0 quickly and there is an incorrect result with gradient.

Simulator Screenshot - iPhone 14 Pro Max - 2023-09-16 at 22 09 50

for example if: width = 2_000 and height = 2_000 , there is no problem: Simulator Screenshot - iPhone 14 Pro Max - 2023-09-16 at 22 12 21

Code to test this bug:

import UIKit
import UIGradient
import TinyConstraints

class ViewController: UIViewController {
	
	lazy var scrollView: UIScrollView = {
		let scrollView = UIScrollView()
		return scrollView
	}()
	
	lazy var view1 = UIView()

	override func viewDidLoad() {
		super.viewDidLoad()
		
		view.backgroundColor = .systemBackground
		
		view.addSubview(scrollView)
		scrollView.edgesToSuperview(usingSafeArea: true)
		scrollView.addSubview(view1)

		let width: CGFloat = 3_000
		let height: CGFloat = 3_000
		
		view1.edgesToSuperview()
		view1.width(width)
		view1.height(height)
		
		let frame = CGRect(origin: .zero, size: CGSize(width: width, height: height))
		view1.backgroundColor = UIColor.fromGradientWithDirection(.topToBottom, frame: frame, colors: [UIColor.blue, UIColor.green])
	}

}

simple demo: TestProject1.zip

HassanTaleb90 avatar Sep 16 '23 19:09 HassanTaleb90