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. 如何設置在UITextField中添加的圖標的位置?
- 2. Swift從輸入座標中添加圖釘位置
- 3. Swift UITextField圖標位置
- 4. 在uitextfield中添加圖標 - iOS Swift
- 5. 如何在谷歌地圖預定義位置添加標記
- 6. 如何在光標位置添加圖像
- 7. 如何在Google地圖上添加當前位置標記
- 8. 如何在swift,cocoa中添加多行標題視圖
- 9. 如何在同一視圖中多次添加標籤 - iOS8 [SWIFT]
- 10. 在TinyMce中添加文本位置的光標,onClick圖標
- 11. 如何在Swift中的選定UITabBarItem圖標下面添加小圖標
- 12. 如何在地圖中的特定位置添加圖片?
- 13. 如何在Swift中爲其位置設置加擾字母?
- 14. 在Titanium中,如何在指定位置添加視圖
- 15. 如何在Swift中正確設置圖像位置?
- 16. 如何在Swift中設置初始地圖位置?
- 17. 如何在TVML的img標籤中添加佔位符圖片?
- 18. Swift:如何添加和動畫圖像視圖內嵌標籤?
- 19. 如何在Outlook 2010中設置圖標大小添加在C#
- 20. 如何在Tableview單元格中獲取UIButton的位置,並在Swift中添加目標?
- 21. 如何在JFXPanel中添加圖標
- 22. 如何在tinymce中添加圖標?
- 23. Swift在UITextField中添加圖像或圖標
- 24. 在當前位置添加標記
- 25. VIM:在光標位置添加空格
- 26. 如何在Swift中的JSQMessagesViewController中添加日期標籤
- 27. 如何在Swift的主視圖中添加子視圖
- 28. 如何在絕對位置添加塊
- 29. 在ScrollView中添加標籤Xcode Swift
- 30. UICollectionView在標題中添加動作(Swift)
再見地圖 – Ved
好創建的UIView,但我怎麼能安裝該系統的部位圖標使用外部圖像白化? (對不起,我的英語) –
有沒有像屏幕右上角的「我」圈 –