I am adding a custom keyboard to a view using inputView linked to a UITextField. I have set the size at Width 216, Height 320. I have it entering from the bottom on a portrait orientation. I want it to only cover 216 pixels of the screen but now when it comes up with the keyboard hugging the left side and has the correct aspect ratio. However there is a gray background that extends from the right edge of the keyboard to the right side of the view. Is there any way to remove this so it is clear and I can see the right side of the view? I have tried setting the background of the view to clear color and tried everything I can think of. Does anyone know if this is possible?
I guess you can't do it, because with keyboard opening the view moves up, so there are the "empty" rectangle in the 216x320 pts.
Related
I have a UIToolBar underneath a navbar, and in this toolbar is a Bar Buttom Item which holds a UISegmentedControl. The problem is I can't add constraints to anything inside the toolbar. The UISegmentedControl pins itself to the left margin when I place it inside the toolbar/bar button item, but then I don't get any dashed blue line when I try to set it width to be the same from the margin on the right side. I see no options to center either, but I don't really want to center, I want to make the segmented control grow in width as the screen goes from iPhone4 to iPhone6+ (in portrait) so that its always some X-pts from the left and right margin. How can I go about doing this?
I have the width of the toolbar, which is 375 for a 4.7inch screen. I can also get the width of the segmented control for this size too, but I can't tell the correct width to make the margins on the left and right the same, I can only eyeball it.
You should add the UISegmentedControl as a direct subview to the UIToolbar (either via addSubview or directly in interface builder). While going the detour around UIBarButtonItem seems convenient here, it deprives you of the possibility to lay things out exactly as wanted, because UIToolbar will handle layout for you and you cannot override this.When you add the UISegmentedControl as a subview, you can add constraints as needed to make it fill the entire width.
I'd like to resize my app components when device is turned into left or right side - when it keep horizontal position
I'm checking device rotation in willRotateToInterfaceOrientation event and then I have to change width of searchBar and tableView. How should I do it? I tried some variants with components .frame and with CGRect, nothing works.
Update:
it can be done without any code. View my answer below
If you laid out your elements in Interface Builder then you can just add an outlet to the width constraint of your search bar. Then, change the constraint's constant property to change the bar's width.
I found the way to do I need
So, the task is that components will be resized in width when device turns horizontally.
1) Select items must be resized
2) Select "Leading Space to SuperView"
3) Without unselection, select "Add missing Constraints"
That's it. Now they will be resized correctly
I want my UITextView to show text but not have the text be as wide as the screen. The problem I face with this, however, is that I want the scrollbar to be in the position it's in now. I'm unsure how to do this. Here's an image of the text i want bringing in, to show you what i mean a bit more clearly:
You can customize the position of the text using the contentInset, contentOffset and contentSize properties of UIScrollView (which is the superclass of UITextView).
It might be a silly question.
I'm trying to set left/right margins like the attached picture. I succeeded to implement it by adding UITextView to UIScrollView.
However, I could achieve almost everything I want with UITextView alone. For example, with UIScrollView, when I manually change the text of UITextView, it automatically scrolls to bottom regardless of setting its .scrollEnabled to No.
It would be perfect if a scroll indicator of UITextView appears outside UITextView.
In the attached picture, let's say the red box represents the entire UITextView. I tried to change UITextView's scrollIndicatorInsets property, but a scroll indicator can be moved only inward to be visible.
Several apps such as Pages, aWriter, Plaintext achieve this feature.
Could you give any suggestion?
Thank you!
I
You can set the scroller right inset value of the UITextView to negative value and disable the clip subview option to achieve your require. No other scrollview is needed.
Alternatively you could set the Right contentInset property.
UIEdgeInsets insets = textView.scrollIndicatorInsets;
insets.right += 5; //add what ever is your margain
textView.scrollIndicatorInsets = insets;
I have a vertically-scrolling UITextView that fills the width of the screen. I need the text view to have margins (contentInset) of 20 pixels on the left and the right. But for some reason, I can't get the right-hand margin to work, either in Interface Builder or in XCode.
The reason I can't just make the text view narrower is because I am adding a subview which needs to run the full width of the screen. Also, I can't turn subview clipping off, because it plays havoc with a load of other elements on the screen.
Anyone know why the contentInset property is not affecting the right margin?
Thanks!
You could add an intermediate view that can be the superview to your text view and what was previously it's subview.
New View with Frame(0,0,width,height)
->TextView with Frame(20,0,width-20,height)
->Subview with Frame(0,0,width,height)