プロジェクトにこれを追加するにはどうすればいいですか?それらはMKMapView
に統合されていますか?場所アイコンをすばやく追加できますか?
インターネットで何も見つけられませんでした。マップビューの上に
プロジェクトにこれを追加するにはどうすればいいですか?それらはMKMapView
に統合されていますか?場所アイコンをすばやく追加できますか?
インターネットで何も見つけられませんでした。マップビューの上に
が希望角を丸めると、ボタンに影や画像を追加するviewDidLayourSubviews
機能で、このコードを記述し、その後その制約を追加MKMapView
の上部にある2つのボタンを作成します。アイデンティティインスペクタから明るい灰色の背景色を選択します。
override func viewDidLayoutSubviews() {
let infoButtonShape = CAShapeLayer()
infoButtonShape.bounds = infoButton.frame
infoButtonShape.position = infoButton.center
let locationButtonShape = CAShapeLayer()
locationButtonShape.bounds = locationButton.frame
locationButtonShape.position = locationButton.center
infoButton.clipsToBounds = true
infoButton.layer.masksToBounds = false
infoButton.layer.shadowColor = UIColor.white.cgColor
infoButton.layer.shadowRadius = 2
infoButton.layer.shadowOpacity = 0.5
infoButton.layer.shadowOffset = CGSize(width: 2, height: -2)
infoButton.layer.shadowPath = UIBezierPath(rect: infoButton.bounds).cgPath
locationButton.clipsToBounds = true
locationButton.layer.masksToBounds = false
locationButton.layer.shadowColor = UIColor.white.cgColor
locationButton.layer.shadowRadius = 2
locationButton.layer.shadowOpacity = 0.5
locationButton.layer.shadowOffset = CGSize(width: -2, height: 2)
locationButton.layer.shadowPath = UIBezierPath(rect: locationButton.bounds).cgPath
infoButton.layer.shouldRasterize = true
locationButton.layer.shouldRasterize = true
locationButtonShape.path = UIBezierPath(roundedRect: locationButton.bounds, byRoundingCorners: [UIRectCorner.bottomLeft , UIRectCorner.bottomRight], cornerRadii: CGSize(width:10.0, height:10.0)).cgPath
infoButtonShape.path = UIBezierPath(roundedRect: infoButton.bounds, byRoundingCorners: [UIRectCorner.topRight , UIRectCorner.topLeft], cornerRadii: CGSize(width:10.0, height:10.0)).cgPath
infoButton.layer.mask = infoButtonShape
locationButton.layer.mask = locationButtonShape
infoButton.contentMode = .scaleAspectFit
locationButton.contentMode = .scaleAspectFit
infoButton.setImage(#imageLiteral(resourceName: "information-icon-3"), for: .normal)
locationButton.setImage(#imageLiteral(resourceName: "LocationArrow-512"), for: .normal)
}
それからちょうど温度とクラウドアイコンのUIImageViewためUILabelを作成する他の二つのUIViewsについて
let manager = CLLocationManager()
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
//Use location.last add to map then stop updating location
manager.stopUpdatingLocation()
}
@IBAction func updateLocationAction(_ sender: UIButton) {
manager.startUpdatingLocation()
}
位置を更新するために、ボタンのIBAction
を加えます。 UILabelとUIImageViewの背景色とそのコーナーの半径については、ボタンの場合と同様のことができますが、今回はUIImageViewの右隅とUILabelの左隅を選択します。
出力は次のとおりです。もちろん、ボタンのサイズを変更したアイコンイメージを使用することもできます。
素晴らしい、ありがとう。明日私はそれを試してみましょう! –
サブビュー。 iはiOSリソースです。 UIButton - >タイプ - >詳細開示
地図 – Ved
オーケー上のUIViewを作成さようなら、しかし、どのように私はセットアップシステムの場所アイコン外部の画像を使用してホワイトアウトすることができますか? (私の英語には申し訳ありません) –
画面の右上にある "i"サークルのようなものがあります。 –