I'm customising the UITabBar in my app. I have 3 tabs so when one is selected it has a background that spans 1/3 of the width of the screen. The only problem is, the screen is 320pt, so divide by 3 and we have a non-integer, thus leaving this horrible gap on the end. I set the background images of the selected state to 106pts and then tried it at 107pts, but that didn't help at all. Here is a picture of the TabBar demonstrating the nasty gap at the end.
It's quite hard to see, but it is there. Does anyone have advice as to how I can get rid of it. This is a subclassed UITabBar so obviously I can make modifications, but I would prefer to keep the fix as simple as possible.
Regards,Mike
Think I've got a little fix, but it's not particularly elegant. I increased the UITabBar width to 321pts so an extra point is being drawn off screen, causing a tab (not sure which one) to expand in size, thus filling the gap.
Give the central element the width of deviceWidth / numberOfTabs + deviceWidth % numberOfTabs, and the others deviceWidth / numberOfTabs. This way the central element will be 108px and the others 106pxs.
Related
I am using swift3 in xcode.
I have made an application with 10 sliders which I rotate to vertical using:
slider1outlet.transform = CGAffineTransform.init( rotationAngle: CGFloat(-Double.pi / 2))
Same goes for slider 2 through 10 this works without a problem,
but I want to add constraints so they go maximum height and are evenly distributed across the width of the screen, and they adapt when I rotate my screen.
This doesn't seem to work, the constraint seems to turn with the slider and I don't want that.
I have made screenshots (with only 3 sliders just for demo purposes)
the first slider has a red background to show what I mean, here is the screenshot of the application without rotating the sliders:
With the rotating sliders (only 1st slider has red background)
I had exactly the same problem, and it took me forever to figure out. I finally ended up writing my own class exactly for this: VerticalSlider.
Simply make new UISliders in your storyboard and set their classes to VerticalSlider.
It took me countless hours of trial and error in one of my projects to make that, so I'm glad I can finally help somebody else :D
I've build this view in inferred size in Xcode 6 -
Every button is in an image view. When i run the app it looks terrible.
I know a little bit about auto-layout but i can't make it look good.
Any tips?
I guess the only way to help you is to suggest you grabbing a good auto-layout tutorial. I guess this one is perfect in your case: https://www.youtube.com/watch?v=IwSTXY0awng
Hope you will get a better understanding of using auto-layout.
Nevertheless if you want some immediate tips, here are some. Remember that I can only guess how the appearance should look like on other screen, it all depends on your vision:
1)Set the trailing space and leading space to superview for the blue rectangle. Don't forget to pin it on the top as well
2) Set leading space for YT and FB buttons, the first should be pinned to the blue rectangle while the latter should be pinned to the bottom of subview.
3) Do the analogy with yellow and green one, but set the trailing space instead of leading space
4) Twitter button should be pinned to fb icon and to the bottom of subview
I'm having some issues with the constraints in my app. Here is how it looks on the iPhone 4 (that's how i want it to look, and how i usually setup my interface, is this the proper approach or not?)
Now, when i switch to the iPhone 5 screen it looks like this
and as you can see, the blue dots (which is UIButtons) are not placed where i want them to be. I made my constraints rely solely on the right side of the view (since that is the one re-sizing, i found that in order for you'r views to align themselves accordingly, it doesn't help to align them to the left side). I don't really know how to fix this. I am finding this new iPhone screen to be a real pain in the arse. Any good advice on how to work with this new screen without a lot of headache would be appreciated :)
Thanks on advance
It looks to me like the are still the same distance from the right side of your view, as you said you set them to be, while the background has stretched to fit the new size. I suspect it's actually the background that isn't doing what you want it to do (keep the same aspect ratio and show more stuff on the left), or try keeping the buttons relating to left and right to stay aligned with the stretched background image.
I'm playing around with an iOS project in Xcode, I've created a new navigation based application, and I'm curious of something. Is it possible to add a margin around the screen, so that the navigation bar, table and toolbar have a few pixels on the top, bottom, left and right? The purpose would be for the entire view of the application to not be 100% of the width and height of the screen, maybe only 95% of each. Not sure if I'm using the right terminology, I'll try to clarify if necessary. Thanks!
Maybe I just didn't ask the question sensibly, but since I can't find an answer, I'm just going to create custom images for navigation bar and toolbar using black space for the margin, and use another question's answer in regards to shortening the width of the UITableViewCells.
I've had this issue come up a couple times doing iPhone development now and have yet to find a good solution for it. What I'm looking for is this:
I want to show some text along with an icon and I want the overall display to be centered within its parent view. Specifically, in my current case, I'm looking to display a box that says "Reconnecting..." with a UIActivityIndicatorView to the left of the text.
Previously, I've just relied on the fact that I know exactly the dimensions of the text and activity indicator, so I can position things absolutely to appear centered. What I'm looking for is something more automatic.
Any ideas?
One of the UIKit additions to NSString will return the pixel size of the text if you give it the font that you're using on the UILabel. So then presumably the total size of the two things together in the layout you describe is:
the difference between label.frame.origin.x and activityIndicatorView.frame.origin.x; plus
the width of the text.
You can then either shuffle both the views appropriately or give them a common parent that's still a subview of the whole thing and shift that.
An activity indicator can be shown in a view just calling a single method.Please click here get SHKActivityIndicator class