im创建UIView时,会在我的布局约束中添加两个TextField子视图,而textFied委托被称为isUserinteractionEnabled设置为true我已经尝试了所有方法,甚至在询问此问题之前都对其进行了搜索:我尝试了textView,但导致smae问题至极这是不可编辑的,我不能写任何东西。
let locationView: UIView = {
let view = UIView()
view.layer.cornerRadius = 15
view.backgroundColor = UIColor.white
view.layer.shadowPath = UIBezierPath(rect: view.bounds).cgPath
view.layer.shadowRadius = 5
view.layer.shadowOffset = .zero
view.layer.shadowOpacity = 1
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
将下面的代码添加到mapView中>]
var mapView: GMSMapView! override func viewDidLoad() { super.viewDidLoad() self.mapView.addSubview(locationView) func setUpLayout() } func setUpGoogleMap(){ let camera = GMSCameraPosition.camera(withLatitude: 15.592778, longitude: 32.552278, zoom: 12) mapView = GMSMapView.map(withFrame: .zero, camera: camera) view = mapView mapView.animate(to: camera) mapView.isMyLocationEnabled = true locationManager.delegate = self locationManager.requestWhenInUseAuthorization() mapView.addSubview(locationView) }
我的布局限制
func setUpLayout() {
locationView.heightAnchor.constraint(equalToConstant: 120).isActive = true
locationView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
locationView.bottomAnchor.constraint(equalTo: locationBtn.topAnchor, constant: -10).isActive = true
locationView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 10).isActive = true
locationView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -10).isActive = true
}
创建UIView时会在编程上添加两个TextField子视图,但我的布局受到限制,优良的是将textFied委托称为isUserinteractionEnabled设置为true我已经尝试过所有方法甚至搜索...
更新您的方法