5

I really like this UI element in Apple's Measure app. How would I go about drawing something that looks like that?

enter image description here

It shouldn't be an image because I would like it to scale according to the text intrinsic size.

Cesare
  • 9,139
  • 16
  • 78
  • 130
  • [`UIMenuItem`](https://developer.apple.com/documentation/uikit/uimenuitem) might help? – Sweeper Dec 22 '18 at 09:04
  • @Sweeper I'm not sure it allows in-depth customization (settings a background color, height, and width plus changing font and tooltip size). – Cesare Dec 22 '18 at 09:08
  • Another approach can be using [an extension of `UIView` that uses a bezier path for the arrow](https://stackoverflow.com/a/64000426/12470155) – Callum Sep 21 '20 at 21:58

1 Answers1

3

3 options

1- UIPopoverPresentationController

2- UIMenuController

3- Usual UIView and the arrow is drawn by QuadCurve

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • I think the `UIPopoverController` has been deprecated – Cesare Dec 22 '18 at 09:28
  • @Cesare yes , it's substitute https://developer.apple.com/documentation/uikit/uipopovercontroller ` `UIPopoverPresentationController` – Shehata Gamal Dec 22 '18 at 09:42
  • `UIPopoverPresentationController` doesn't work on iPhone in portrait mode (a view controller is presented modally in full screen). – Cesare Dec 22 '18 at 10:54
  • @Cesare i used it many times and it works in iphone , it's a bit very old when it was only run on ipad – Shehata Gamal Dec 22 '18 at 18:08
  • 1
    @Cesare it works if you implement the UIPopoverPresentationControllerDelegate method, ***adaptivePresentationStyle*** and return **.none**. [SO]: https://stackoverflow.com/questions/25319179/uipopoverpresentationcontroller-on-ios-8-iphone – hidden-username Jun 03 '19 at 13:09