Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HassanTaleb90 opened this issue Sep 16, 2023 · 0 comments
Open

Comments

@HassanTaleb90
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant