Xamarin Forms Iphone X remove padding - xamarin

I've tried everything to remove the top padding in IPhone X, including setting this on the page code behind:
var safeInsets = On<iOS>().SafeAreaInsets();
safeInsets.Top = 0;
Padding = safeInsets;
and in Xaml
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
ios:Page.UseSafeArea="False"
ios:Page.PrefersStatusBarHidden="True"
NavigationPage.HasNavigationBar="False"
Still getting this padding at the top. I'm probably missing or not understanding something. I've read all the Xamarin guides, many forum posts, etc. How do I get the image to go all the way to the top?

Related

How to change the picker items font size in Xamarin IOS?

In Xamarin forms, for IOS if the picker item has lengthy text, that text is getting truncated. How to change the xamarin ios picker items font size using customrenderer or how to make the text fit without getting truncated?.
There is another alternative solution as well where you can change the alignment of Picker Item(Default is Center). You can make it left.
For adjusting Text and Style there are plenty of renderer solutions on Stack Overlfow.
For your ref, attaching one of those solutions.
Solution.

How to alter text of label based on if the text would overflowing - in Xamarin forms

I have a UI requirement for displaying the user name list like the ones that appear on social media posts for displaying people who liked the post.
The problem in it is the overflow thing.
if it's a single user. Simply display them.
If it's a long list and overflows the label length then out the overflowing user names has to removed and replaced with remaining user count text.
Since I search through web and found no Xamarin Forms way of doing this. I am thinking of creating a custom renderer for this and using native text measuring API to figure the text to be displayed.
Android
var textSize = paint.MeasureText(this.Control.Text);
iOS
NSAttributedString nS = new NSAttributedString(txt, font: this.Control.Font);
var textSize = nS.Size;
Am I in right path? Is there any other way of doing this?

How to do a page curl flipping in xamarin forms

I need to implement a page flip animation in my xamarin forms app.I tried with flipping but that doesn't give a perfect look.
I want a page flip like below link.
https://youtu.be/s-Q12A-Pej4
Please help me.
you can write below code in xaml.cs for Page Flip Animation .
this.TranslateTo(100, 0, 400);
await this.RotateYTo(-90, 200);
this.RotationY = -270;
this.RotateYTo(-360, 200);
await this.TranslateTo(0, 0, 220);
this.RotationY = 0;
this is basic logic for FlipAnimation you can modified if needed

How to give width to the TabViewItem in Nativescript?

I want to implement sometthing like above where the camera tab has the smaller width compare to the others tab in TabView.
I did three tabs with same size but I don't know how to add one more tab but with smaller width.
You will have to update the width of native view that contains the camera within the tab layout. The code below lets the layout take only the width it requires to show the content within.
const view = nativeTabView.getChildAt(i),
layoutParams = view.getLayoutParams();
layoutParams.weight = 0;
layoutParams.width = android.widget.LinearLayout.LayoutParams.WRAP_CONTENT;
view.setLayoutParams(layoutParams);
Playground Sample
The above example is written in NativeScript Core / TypeScript, there is nothing you have to specifically if you are implementing this on Vue / Angular, just use the appropriate event binding syntax, you should be good.

UIScrollView contentLayoutGuide and zooming centered

The problem to be solved here is how to zoom in a UIScrollView while staying centered. If you don't take some sort of precautions, the default is that as we zoom out, the zoomed view slides up to the top left corner of the scroll view, like this:
So how to prevent this, and keep the zoomed view in the center as we zoom? As you probably know, there are traditional ways of handling this by messing with the scroll view's layout, as described by Josh and Eliza in the brilliant classic WWDC video 104 from 2010. This can be done by using a delegate or by subclassing UIScrollView, and gives the desired result:
Now comes WWDC 2017 video 201 (https://developer.apple.com/videos/play/wwdc2017/201/?time=1496), and there's Eliza making a claim that the new (iOS 11) contentLayoutGuide solves the problem of zooming while staying centered in a new way: she says to center the content view at the center of the content layout guide.
But she doesn't demonstrate. And when I try it for myself, I find it isn't solving the problem. I'm zooming in just fine, but when zooming out, so that the zoom scale is smaller than 1, the content view moves up to the top left, just as it always has.
Has anyone figured out what this claim in the video actually means? How does iOS 11 make it easier to zoom centered than in the past?
EDIT I actually received a sample project from Apple in response to my bug report, which they claimed illustrated how to solve this, and it didn't! So I conclude that even Apple doesn't know what they're talking about here.
The view goes to the top left because the contentSize of the scroll view is not defined. When using the new Auto Layout guides in iOS 11, it's still necessary to define the contentSize.
Add the following constraints:
scrollView.contentLayoutGuide.widthAnchor.constraint(equalTo: scrollView.frameLayoutGuide.widthAnchor),
scrollView.contentLayoutGuide.heightAnchor.constraint(equalTo: scrollView.frameLayoutGuide.heightAnchor)
This worked for me, when I had a contentView with a fixed width/height and the following additional constraints:
// give the centerView explicit height and width constraints
centerView.widthAnchor.constraint(equalToConstant: 500),
centerView.heightAnchor.constraint(equalToConstant: 500),
// pin the center of the centerView to the center of the scrollView's contentLayoutGuide
centerView.centerXAnchor.constraint(equalTo: scrollView.contentLayoutGuide.centerXAnchor),
centerView.centerYAnchor.constraint(equalTo: scrollView.contentLayoutGuide.centerYAnchor)
This is the solution you are / everybody is looking for. In my case I want to center a view inside a table view scroll view. So if the table view scrolls the custom view will always be in the center of the scroll view content.
// create a view
let v:UIView = UIView(frame:CGRect.zero) // use zero if using constraints
ibTableView.addSubview(v)
ibTableView.bringSubview(toFront:v)
v.translatesAutoresizingMaskIntoConstraints = no
v.backgroundColor = .yellow
v.widthAnchor.constraint(equalToConstant:100).isActive = yes
v.heightAnchor.constraint(equalToConstant:100).isActive = yes
// set scrollview guides
ibTableView.contentLayoutGuide.widthAnchor.constraint(equalTo:ibTableView.frameLayoutGuide.widthAnchor).isActive = yes
ibTableView.contentLayoutGuide.heightAnchor.constraint(equalTo:ibTableView.frameLayoutGuide.heightAnchor).isActive = yes
// anchor view
v.centerXAnchor.constraint(equalTo:ibTableView.contentLayoutGuide.centerXAnchor).isActive = yes
v.centerYAnchor.constraint(equalTo:ibTableView.contentLayoutGuide.centerYAnchor).isActive = yes

Resources