Skip to content

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

@HassanTaleb90

Description

@HassanTaleb90

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions