Post

Replies

Boosts

Views

Activity

UITextView does not show
Hello. Like the title says i am trying to creating a TextView. It is supposed to be in a UIView which already contains another UIView which poses as a fake top border. The border is where it is supposed to be, but the TextView won't show. Does anybody what i am doing wrong? Here is the code: 	let jobView = UIView.init(frame:CGRect.zero) 		 let topBorder = UIView.init(frame:CGRect.zero) 		 let jobTitleText = UITextView.init(frame:CGRect.zero) 		 jobView.translatesAutoresizingMaskIntoConstraints = false 		 topBorder.translatesAutoresizingMaskIntoConstraints = false 		 jobTitleText.translatesAutoresizingMaskIntoConstraints = false 		 jobTitleText.text = job.title 		 jobTitleText.textColor = UIColor.black 		 jobTitleText.font = UIFont.boldSystemFont(ofSize: 20) 		 jobView.addSubview(topBorder) 		 jobView.addSubview(jobTitleText) 		 NSLayoutConstraint.activate([ 		 topBorder.topAnchor.constraint(equalTo: jobView.topAnchor), 		 topBorder.centerXAnchor.constraint(equalTo: jobView.centerXAnchor), 		 topBorder.heightAnchor.constraint(equalToConstant: 15.0), 		 topBorder.widthAnchor.constraint(equalTo: jobView.widthAnchor) 												]) 												 		 NSLayoutConstraint.activate([ 		 jobTitleText.topAnchor.constraint(equalTo: topBorder.bottomAnchor, constant: +5.0), 		 jobTitleText.heightAnchor.constraint(equalToConstant:25.0), 		 jobTitleText.leadingAnchor.constraint(equalTo: jobView.leadingAnchor, constant: +5),
1
0
325
Dec ’20
ScrollView won't scroll
Hello. I have successfully created a scrollview with several buttons that stack on top of one another. But the View won't scroll. What am i doing wrong here? scrollView = UIScrollView.init(frame: CGRect.zero) &#9;&#9;&#9;&#9;scrollView.translatesAutoresizingMaskIntoConstraints = false &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;self.view.addSubview(scrollView) &#9;&#9;&#9;&#9;var leadingAnchor = self.scrollView!.topAnchor &#9;&#9;&#9;&#9;for i in 0..<20{ &#9;&#9;&#9;&#9;&#9;&#9;let t_button = UIButton.init(frame: CGRect.zero) &#9;&#9;&#9;&#9;&#9;&#9;t_button.translatesAutoresizingMaskIntoConstraints = false &#9;&#9;&#9;&#9;&#9;&#9;t_button.backgroundColor = UIColor.blue &#9;&#9;&#9;&#9;&#9;&#9;scrollView.addSubview(t_button) &#9;&#9;&#9;&#9;&#9;&#9;NSLayoutConstraint.activate([ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;t_button.topAnchor.constraint(equalTo: leadingAnchor, constant:5.0), &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;t_button.centerXAnchor.constraint(equalTo: scrollView.centerXAnchor), &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;t_button.heightAnchor.constraint(equalToConstant: 50.0), &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;t_button.widthAnchor.constraint(equalToConstant: 75.0) &#9;&#9;&#9;&#9;&#9;&#9;]) &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;leadingAnchor = t_button.bottomAnchor &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;t_button.setTitle("Button \(i)", for: .normal) &#9;&#9;&#9;&#9;&#9;&#9;t_button.addTarget(self, action: #selector(scrollViewButtonAction(_:)), for: .touchUpInside) &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;NSLayoutConstraint.activate([ &#9;&#9;&#9;&#9;&#9;&#9;scrollView.topAnchor.constraint(equalTo: self.titleHeader.bottomAnchor, constant: 10.0), &#9;&#9;&#9;&#9;&#9;&#9;scrollView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor), &#9;&#9;&#9;&#9;&#9;&#9;scrollView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor), &#9;&#9;&#9;&#9;&#9;&#9;scrollView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor), &#9;&#9;&#9;&#9;])
3
0
6.5k
Dec ’20