Is there a way to set the backgroundColor of the bar that contains the inputAssistantItem elements? (the bar that contains the "next" button in the image):
Also, is it possible to add a UILabel (like a title) to the bar?
I suggest you use inputAccessoryView as it is a UIView you can just do pretty much everything you want with it.
I opened the "UITextInput.h" file and there seems to be no way to achieve what you want as the object does not give you the tools.
This is the code I found
NS_CLASS_AVAILABLE_IOS(9_0) __TVOS_PROHIBITED __WATCHOS_PROHIBITED #interface UITextInputAssistantItem : NSObject
/// Default is YES, controls if the user is allowed to hide the shortcuts bar. Does not influence the built in auto-hiding logic.
#property (nonatomic, readwrite, assign) BOOL allowsHidingShortcuts;
/// Contains UIBarButtonItemGroups that should be displayed in the leading position on the keyboard's assistant bar.
#property (nonatomic, readwrite, copy) NSArray<UIBarButtonItemGroup *> *leadingBarButtonGroups;
/// Contains UIBarButtonItemGroups that should be displayed in the trailing position on the keyboard's assistant bar.
#property (nonatomic, readwrite, copy) NSArray<UIBarButtonItemGroup *> *trailingBarButtonGroups;
#end
BAD POSSIBLE SOLUTION could be checking the superview of the buttons you create until you find the toolbar and then trying to change what you want. I honestly recommend you NOT TO DO THIS.
Related
Basically I want to make something similar to this gmail bar http://i.stack.imgur.com/sYWhj.gif.
Right now I am able to make the whole bar and make it progress
These are 3 view properties.
#property (nonatomic, readwrite, strong) UIView *progressBarView;
#property (nonatomic, readwrite, strong) UIImageView *progressBarBackground;
#property (nonatomic, readwrite, strong) UIImageView *progressBar;
and I add progressBarBackground and progressBar as subview in progressBarView.
For bar progress animation I just use
CGRect frame = self.progressBar.frame;
frame.size.width = MAX(kProgressBarMinWidth, kProgressBarWidth * self.progress);
[UIView animateWithDuration:duration
animations:^{
self.progressBar.frame = frame;
}];
But I am having problem adding that left to right animation in the gif. Anyone knows how to do that?
That looks to me to be a pattern-based color fill, and then animating the origin of the pattern. Take a look at the UIColor class method colorwithPatternImage
I want to set up a constrain in storyboard but deactivate it in Storyboard
for a while, until a user interaction happens. Is it possible?
Try setting constraint.active to NO, then set it back to YES to re-enable it.
If you want to disable it in the storyboard, go to the Identity inspector(), then click the + button under the User Defined Runtime Attributes header. Double-click the section of the highlighted row that says “keyPath”. Type in active, then uncheck the checkbox.
Yes it is possible.
Create an IBOutlet for that NSLayoutConstraint and connect it your mentioned contraint in Storyboard.
#property (nonatomic, strong) IBOutlet UIView *myView;
#property (nonatomic, strong) IBOutlet NSLayoutConstraint *myConstraint;
myConstraint is a constraint on myView
On viewDidLoad write this code: [_myView removeConstraint:_myConstraint];
Then, when a user interaction happens: [_myView addConstraint:_myConstraint];
Can I make my UIView #property inspectable?
#interface Superview : UIView
#property (nonatomic, weak, readonly) IBInspectable UIButton *stopButton;
#property (nonatomic, weak, readonly) IBInspectable PKCircleProgressView *circleProgressView;
#end
I've created a designable view PKCircleProgressView, and I want it to be editable from the IB. Also I've created another designable view which contains PKCircleProgressView as subview, and I want it to be editable too.
Is there any way to edit circleProgressView's properties if I use Superview in the IB?
I've come out only with one idea, to create a common protocol for both views, and implement methods such as:
- (void)setProgress:(CGFloat)progress {
self.circleProgressView.progress = progress;
}
but it is not easy to do it with every property, especially if I want to create another View that contains my Superview.
IBInspectable does not support UIView or it's subtypes. It supports simple values.
If your custom progress view is IBDesignable why not set it's properties like radius and foreground color to be IBInspectable and in interface builder select the progress view and change the progress view's properties?
If your creating an IBDesignable superview you might be able to expose the inspectable properties of it's button and progress view using something like the Decorator pattern.
Apple's Documentation
No you cannot make UIView Inspectable. The usage of IBInspectable is only for configuring "key value" coded property of an instance in a NIB or storyboard.
Suppose, if UIView will be the key then what will be its value? There won't be value for UIView, so you cannot make UIView Inspectable.
But we can make UIView's attributes Inspectable such as:
UIView's backgroundColor, width, height, etc
Sample project: IBDesignable and IBInspectable
i'm trying to create an ui button with image and text.
What i need is simple:
an image centered on the first row and on another row a label centered.
So i've created an uibutton in my storyboard, set text and background in this way:
But the result isn't good for me.
This is what i have:
and this is what i need:
Can someone help me?
thanks!
EDIT
I've created a custom UIButton in this way:
.h
#import <UIKit/UIKit.h>
#interface MenuButton : UIButton
#property (weak, nonatomic) IBOutlet UIImageView *image;
#property (weak, nonatomic) IBOutlet UILabel *text;
#end
.m
#import "MenuButton.h"
#implementation MenuButton
#end
And in interface builder i create a view with class MenuButton addedd an image and a label and connecting to .h.
Now my question is:
How can i pass to that new button the image and the label in order to instantiate multiple "custom button" with different value inside?
Thanks!
You just create a UIButton subclass.
1)
If you are using IB: then you can create 2 properties in the .h
#property (weak, nonatomic) IBOutlet UIImageView *image;
#property (weak, nonatomic) IBOutlet UILabel *text
next you need to connect all the properties to the objects in the IB
If you are using code the remove the IBOutlet and move the properties to the .m
2)
Now all you need to do is manage the behaviour of the properties.
in IB, just add the autolayout constraints to the subclass and change their constant property value - check this tutorial
in code, you can do this by setting their frame with animation to make them larger/smaller
EDIT
Ok, after reading your update you need to change the subclass from UIButton to UIView.
This way you can add a UIView in your storyboard and add the UImageView & UILable. After doing so you can change the UIView's class to your subclass.
Then, click on the UIView and open the connections inspector. You will see the IBOutlets you have declared in th UIView subclass, you can just drag from the connections inspector to the UIImageView & UILabel to crete the connections
Very simple question: How do I add a UIReturnKey to a UIKeyboardTypeDecimalPad? If I assign the textField.returnKeyType = UIReturnKeyNext; to the textfield, nothing happens (as it normally would given any other keyboard type).
Thanks.
Normally UIKeyboardTypeDecimalPad does not have return key for iPhone but you can add your own buttons using
#property (readwrite, retain) UIView *inputAccessoryView
property of UITextfield