Does anyone have a clue what is the actual distance from the screen's left edge to the back button of the UINavigationBar ?
Because I know that we cannot change in anyway the coordinates of it, so we can only use some other workarounds to mimic that if we need to offset the button with more / less.
The button itself has absolutely no padding or space between the left edge of the navigation bar and itself. Meaning you can tap at the very first pixel of the bar, and it will "touch" the back button.
If you mean how far it is from the left edge of the navigation bar to the beginning of the back button's image. Then exactly 16px on a retina display.
But that means you would reference the gap as 8px in your code, since iOS will automatically scale up on an #2x display.
(All these values were found from using the iOS simulator and Pixie.app.
Related
Moving a view I try to hide all parts of view that cross some vertical line, so view starts to loose its width to 0.
The image describes better what I want.
I mean not just shrink a width with scaleX but hide, because this command compresses the photo horizontally, and I need to hide it without distortion.
How can I do it?
On the image a photo started to move left with translationX hiding line by line left side of the photo during this movement. Also, the photo is not at left edge of screen - it's on the center
View has left(and x) attribute in its LayoutParams.
How can I dynamically set the position of view in Android?
When left attribute is negative, it is hidden under the parent view.
If you want an animation, here is the document!
https://developer.android.com/develop/ui/views/animations/reposition-view
I have settings screen within my game for resolution. Within this setting page, you have a fullscreen ON and OFF option. I also have a resolution switcher above it. However when you turn fullscreen off and change the resolution. The game is no longer centered on the screen and moves around as you change the resolution. I have tried many things such as window_center() within the switch statement. However this isnt solving my issue. Does anyone have any ideas on how to keep the game centered on the screen when changing resolutions with fullscreen turned off? (Such as a windowed fullscreen)
You'll want to either delay window_center call by 1 frame (as the window position data doesn't update till the end of the frame), or use window_set_rectangle to calculate position yourself immediately, like so
window_set_rectangle((display_get_width() - width) div 2, (display_get_height() - height) div 2, width, height);
(or slightly more complex if you want to resize window relative to the current position)
Introduction
This is a rather common question, however I have certain extra points to observe. One of them is that I don't want to make my bars opaque. I like the iOS7 translucent bars.
I have an UIImageView inside a UIScrollView, and I'm trying to set the initial scrollView.zoomScale to fit the image in the screen just like the stock Photos app does. That means: the image should not be cropped and should fill the screen as much as possible.
However for my app this is a bit more complicated as I have visible statusBar, navigationBar and tabBar. I will adopt the solution to hide them until the user touches the screen, but I'm still curious for a solution when hiding is not desirable.
Done so far
I'm currently calculating the zoom based on a relation between the image's height and the view's height:
double heightRelation = self.image.size.height / self.view.frame.size.height;
After applying 1/heightRelation to the scrollView.zoomScale, the image is still bigger than the useful space. Then I found the iOS7 default heights for statusBar (20pt), tabBar (49pt) and navigationBar (44pt) from the documentation and also from:
NSLog(#"status : %f", CGRectGetHeight([[UIApplication sharedApplication] statusBarFrame]));
NSLog(#"tab : %f", self.tabBarController.tabBar.frame.size.height);
NSLog(#"nav : %f", self.navigationController.navigationBar.frame.size.height);
... and after playing a little, I found that the exact combination would be to subtract statusBar and navBar heights from the view's height:
double heightRelation = self.image.size.height / (self.view.frame.size.height - CGRectGetHeight([[UIApplication sharedApplication] statusBarFrame]) - self.navigationController.navigationBar.frame.size.height);
This works great for the Portrait mode, but doesn't for Landscape. I know I could also make a condition to set the zoom according to the orientation but... The code is probably getting unnecessarily ugly.
So I ask you: what's the best method to get the useful height?
P.S.: Interface Builder's option "Adjust Scroll View Insets" has no effect.
Don't use the bars directly. Use the length properties of bottomLayoutGuide and topLayoutGuide of the view controller to determine how much of the view is "wasted" under the bars. These take into account navigation bars, toolbars, status bar, tab bars, etc., and are maintained by the system when the bars are resized (for example, after rotation to landscape on phone/pod idioms).
In iOS 7, the Phone dialling app has a round translucent rim and tapping on the button you can see a blurred version of the wallpaper you've set.
Is there a standard way of making such translucent rimmed buttons that blur the background only around the rim?
The short answer is that there is not a standard way to do this. There are however several techniques that can be used to achieve this blur effect.
Essentially, every drawRect:, you want to capture the background, blur it and adjust the saturation and brightness, and then mask it to the circle border.
If you want the entire button to be blurred when pressed, you could check for that state in the button and then adjust the mask to include the whole button and maybe reverse the text so that it is still readable.
I want a background image to always be aligned with the bottom of the screen regardless of screen size, iOS Version, or Personal Hotspot messages etc. But none of the interface builder alignment options seem to work in every case.
I have 2 different sized images to fit 3.5' and 4' retina which change via code but their alignment is always thrown off by 'Personal Hotspot' and other messages changing the size of the parent view.
My images are the size of the screen and should fill the whole screen always. There is a black area where tab bar and status bar will overlay.
There are buttons aligned with the background and everything gets thrown out by messages that resize the parent view.
I want the bottom of the UIImageView to be aligned with the bottom of the screen always.
have you tried the contentMode property?
theImageView.contentMode = UIViewContentModeBottom;
There is also a menu item for this in interface builder if you prefer to set it there.
then if you are using auto layout, simply add a bottom space constraint from your image view to the bottom layout guide.
If you're not using auto layout, a fixed bottom margin on the autoresizing mask should do the trick.