0
A
回答
0
上創建
MKMapView
的頂部的兩個按鈕添加則它們的約束在viewDidLayourSubviews
功能編寫此代碼舍入所希望的角部和陰影和圖像添加到按鈕。從身份檢查員中選擇他們的淺灰色背景顏色。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) }
然後添加按鈕的
IBAction
更新位置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() }
對於兩個其它UIViews只是創建一個UILabel用於溫度以及用於雲圖標一個的UIImageView。對於UILabel和UIImageView的背景顏色及其圓角半徑,您可以做類似於我爲按鈕所做的操作,但是這次爲UIImageView和UILabel的左角選擇了正確的角點。
這裏是輸出:當然,您可以使用更好的大小的圖標圖像爲您的按鈕。
+0
很棒,謝謝。明天我會試試它! –
0
子視圖在地圖視圖的頂部。我是一個iOS資源。的UIButton - >型 - >詳細披露
相關問題
- 1. Swift UITextField圖標位置
- 2. 如何在光標位置添加圖像
- 3. 如何在Google地圖上添加當前位置標記
- 4. 在TinyMce中添加文本位置的光標,onClick圖標
- 5. 如何在同一視圖中多次添加標籤 - iOS8 [SWIFT]
- 6. 在Titanium中,如何在指定位置添加視圖
- 7. 如何在Swift中爲其位置設置加擾字母?
- 8. 如何在Swift中設置初始地圖位置?
- 9. 如何在TVML的img標籤中添加佔位符圖片?
- 10. 如何在tinymce中添加圖標?
- 11. VIM:在光標位置添加空格
- 12. 在當前位置添加標記
- 13. 如何在Tableview單元格中獲取UIButton的位置,並在Swift中添加目標?
- 14. Swift在UITextField中添加圖像或圖標
- 15. 如何在iPhone應用程序中添加某個位置的位置預覽圖標?
- 16. 如何在Swift中的JSQMessagesViewController中添加日期標籤
- 17. UICollectionView在標題中添加動作(Swift)
- 18. 在ScrollView中添加標籤Xcode Swift
- 19. 如何在Swift中使用GPS座標在地圖上添加多個註釋?
- 20. 如何在Swift Project中添加Alamofire
- 21. 如何在tableView中添加動畫Swift
- 22. 如何在Swift中添加邊距
- 23. 如何在uialertview中添加uipickerview swift 3
- 24. 如何在位圖上添加邊框
- 25. 如何在swift中更改Google地圖的myLocationButton的位置
- 26. swift 3如何添加一個按鈕,刷新位置和縮放我的位置地圖工具包
- 27. 在Google地圖上添加標記到當前位置
- 28. 在Google地圖上單擊任意位置時添加標記
- 29. 如何在Swift中將圖像添加到ScrollView中
- 30. 如何在swift中的標籤欄項目中設置圖像?
再見地圖 – Ved
好創建的UIView,但我怎麼能安裝該系統的部位圖標使用外部圖像白化? (對不起,我的英語) –
有沒有像屏幕右上角的「我」圈 –