AirPlay Button Custom Sizing - ios

I have an Airplay Button which I have created by subclassing a UIButton to AVRoutePickerView in Storyboard. It's showing the button and also showing the view when tapped. I am unsure how I can change the size of the icon though. Have I created the Airplay Button incorrectly or am I just missing something?

I don't think you want to use a UIButton. An AVRoutePickerView is a UIView, not a UIButton. It creates a UIButton and inserts it as a subview of itself. That's the button you want to resize.
You can access AVRoutePickerView's button by doing this hackery:
let button = routePickerView.subviews.first(where: { $0 is UIButton }) as? UIButton
You can then experiment with changing its frame size... maybe directly or via constraints.
Just beware that this hackery isn't future-proof. Apple could change how it manages the button in the future.

Related

Tap not working if SVG Image inside UIControl

I am writing an iOS App in Swift 4.
I need a custom button with SVG image inside it.
So, I added UIView in Storyboard scene > Changed it to UIControl as custom class > Traits: Button and User interaction Enabled.
Then I added SVGView (Macaw) inside it, Constraints 0,0,0,0 and unchecked all of its traits.
The issue is this button isn't taking any tap (TouchUpInside) gestures.
check is user interaction enabled for the image?

Custom iOS Keyboard

I want to add a keyboard icon to the bottom left grey square on UIKeyboardType.NumberPad. How can this be done?
Some ideas I have went through.
class that conforms to UITextInputTraits I couldn't figure out what was required to satisfy the protocol.
UIButton above the keyboard
subclass of UIView and not use a keyboard at all. This one seems the hardest.
If you want to show a custom view in the bottom, you have to add a subview to the keyboards window view so it overlays the keyboard.
The Keyboard is shown on a separate window UIRemoteKeyboardWindow
Run this code AFTER the keyboard gets shown:
let view = UIButton(frame: yourFrame)
UIApplication.sharedApplication().windows.last?.addSubview(view)
It's the cleanest solution that requires the least work.

iOS : subclassing UINavigationBar for custom title view

I've subclassed UINavigationBar, I wanted to have a UIView contains UIImageView + UILabel inside it, I'm able to achieve it by setting titleView property. But, what I want to know is whether its possible to add it inside subclass directly?
Better way add one UIView on Navigationbar and then add any component on that so it is easy to manage those component because if you add component on left button right button and title label it not that much flexible to customise (i.e. if you added any component on titleLabel you can set that component frame only equal or less that title label. but if you add on UIView on Navigation bar then you can customise all components easily)
I hope it will help you.

Avoid UIButton overlay on UIPickerView ios

I am started to learn iOS. I am doing small app. In that I placed UIPickerView and UIButton in ViewController. On view controller tap, UIPickerView will show to the user. On showing, the detail, UIButton also show (overlay on UIPickerView). How can I Put the UIButton back to viewController.
How to avoid inappropriate view.?
See the update button in UIPicker view
this depends on the order you add your subviews to your view. try [viewController.view sendSubviewToBack: yourButton]
in interface builder drag the view you want to place on top of your view hierarchie to the bottom. on the picture UISegmentedControl would overlap the UIButton if not properly aligned.
Go to your xib file and drag your Picker object to the bottom of its container as in the image below:

uitoolbar with icons/text similar to uitabbar

Ideally I want to use a UIToolbar but I want the icons at the bottom to appear as they would in a UITabBar meaning with icon for default and highlighted states and title beneath. I know I can drag a UIButton onto the toolbar and it will create a UIButton inside of a UIBarButtonItem, but I can't seem to manipulate the UIButton to show a title beneath? The other problem I'm having is when I set the alignment of the button in IB (in the Control section) it only changes the alignment for the default state not the highlighted state. Can anyone give me some pointers here that would be great thanks!
rc
Putting the UIButton inside a UIBarButtonItem is the best way I've found to do it. Just set the text for the button and it should show up fine. When manipulating the positioning, remember you're manipulating the position of the UIBarButtonItem and not the UIButton. Hope that helps!

Resources