I try to customize UIAlertView
Is it possible use Appearance API to customize button inside UIAlertView?
Thanks.
Unforunately no, you are not able to customize the button appearance on a UIAlertView using UIAppearance. When it comes to customization UIAlertView can seem a little locked down. Having said that though there are a few resources out there with examples of people doing what you are saying. Here on SO there is an answer to a similar question using objective-C.
Customizing the buttons on a UIAlertView
Converting that to C# for use in Xamarin shouldn't be too hard and would look something like this:
var av = new UIAlertView( );
av.AddButton( "" );
var button = av.Subviews.Last( );
button.Hidden = true;
var newButton = new UIButton( UIButtonType.Custom );
av.AddSubview(newButton);
av.Show();
newButton.SetImage(...);
newButton.AddTarget(...);
newButton.Frame = button.Frame;
Related
I have define a custom actions in my accessibilityElement:
UIAccessibilityCustomAction *action1 = ...initWithName:#"label1";
UIAccessibilityCustomAction *action2 = ...initWithName:#"label2";
element.accessibilityCustomActions = #[action1, action2];
When swipe down/up, it reads "Drag" in addition to the normal "label1", "label2", what is this "Drag" and how did it come about?
For anyone that comes along and sees this, I was having the same issue, and I was able to find that Apple added (sometime around iOS 11) the UITextDraggable protocol to UITextView.
This is defined as:
The interface that determines if a text view is a drag source.
This protocol has the property textDragInteraction that defaults to true for UITextViews.
You can set this property to false like this:
Swift:
textView.textDragInteraction?.isEnabled = false
Obj-C:
textView.textDragInteraction.enabled = NO;
Is there a way in Swift to force the iOS keyboard to not have the top part? By saying the top part I mean the autocomplete and the input field switcher tools that appear at the top.
Some of my views have embedded webViews that run local js and I want the keyboard for the inputs in webView to not have that top part of the keyboard. If it`s not possible to disable these for webView specifically, any other method should be fine as well.
Please take a look at this screenshot to see exactly what part of the keyboard I am talking about.
You can try running the below JS in the webview every time you load the web page
var textFields = document.getElementsByTagName('input');
if (textFields) {
var i;
for( i = 0; i < textFields.length; i++) {
var txtField = textFields[i];
if(txtField) {
txtField.setAttribute('autocomplete','off');
txtField.setAttribute('autocorrect','off');
txtField.setAttribute('autocapitalize','off');
txtField.setAttribute('spellcheck','false');
}
}
}
Additionally write this code to hide the done button accessory view from keyboard
class CustomWebView: WKWebView {
var accessoryView: UIView?
override var inputAccessoryView: UIView? {
return accessoryView
}
}
And use CustomWebView in place of WKWebView wherever this functionality is needed.
Let me know if you need any more help.
Happy Coding :)
I'm trying to be clever about setting all title properties of the the "Back" buttons in a UINavigationController so that I don't have to do self.navigationController.navigationBar.backButtonItem.title = "Back" everywhere or subclass a UINavigationController and set it everywhere, so I've created this extension:
extension UINavigationItem {
open var backBarButtonItem: UIBarButtonItem? {
get {
return self.backBarButtonItem
}
set {
newValue?.title = "Back"
backBarButtonItem = newValue?
}
}
}
But it says 'backBarButtonItem' used within its own type.
Has anybody done this before or can think of a way to make it work?
You are getting this error because you cannot create a variable with the name which is similar to those variables which are defined in the SDK.
You can't override the existing functionality
Like in your case you are naming it as backBarButtonTitle which is defined as open var backBarButtonItem: UIBarButtonItem? in UINavigationBar class of UIKit
As it is mentioned in doc of Apple
Extensions can add new functionality to a type, but they cannot
override existing functionality.
Please follow this Screen shot Image then run your project . I think you can solved your problem easily :)
I have a following code:
textView.returnKeyType = UIReturnKeyType.Done
that makes my keyboard look like this:
but I would like to get rid of the done/return button and achieve this:
what's the best way of doing it in swift?
You cannot achieve this by changing the return button type, instead you need to change the keyboard type. In order to change the keyboard type to match the one you posted that you would like to match, use the twitter keyboard type.
Swift 2
textView.keyboardType = .Twitter
Swift 3
textView.keyboardType = .twitter
I have been set to make some changes to a Xamarin IOS project (which I am total new to), and I quickly found out, that our project does not work as it should.
// save our uiview owner
this._owner = owner;
// configure the title label
_titleLabel.BackgroundColor = UIColor.Clear;
_titleLabel.TextColor = Colors.backgroundcolor;
_titleLabel.Font = Fonts.HelveticaNeueLight();
// configure the done button
_doneButton.SetTitle("OK", UIControlState.Normal);
_doneButton.TouchUpInside += (s, e) => { _actionSheet.DismissWithClickedButtonIndex(0, true); };
_doneButton.SetTitleColor(Colors.backgroundcolor, UIControlState.Normal);
_doneButton.SetFont(eFontType.HelveticaNeue_Light, 14);
// create + configure the action sheet
_actionSheet = new UIActionSheet() { Style = UIActionSheetStyle.BlackTranslucent };
_actionSheet.Clicked += (s, e) => { Console.WriteLine("Clicked on item {0}", e.ButtonIndex); };
// add our controls to the action sheet
_actionSheet.AddSubview(picker);
_actionSheet.AddSubview(_titleLabel);
_actionSheet.AddSubview (_doneButton);
^this was how it was created, and added some label, button and a datepicker.
We were using a UIActionSheet to show a Datepicker. But as I can see, IOS8 does not support this way to handle it anymore.
And I am clueless how we can make it work with UIAlertController - I cannot find any good examples.
Please see this post from the Xamarin Forums iOS 8 Datepicker
To quote,
Now the Actionsheet can't add Subviews anymore
So here is a Github link for a replacement for the ActionSheet Datepicker. I just implemented this in my app and its working well. Github Replacement
In the forum post there is a step by step link to integrate into your project.