简体   繁体   中英

Constraints doesn't work for Ipad xamarin.forms

I am working with xamarin.forms and using constraints to center and scale a logo in my splash screen. The problem is: The constraint that I define to Iphone 5s, 6, 6s etc.. doesn't work to the Ipad, and when I define it to the Ipad, it doesn't work to Iphones... Does someone know how to solve that?

Iphones contraint (in right positions etc):

在此处输入图片说明

Ipads constraint (it's is wrong here):

在此处输入图片说明

If you just want to center the logo in the screen, I am not sure why you would go with different Size classes for iPhone and Tablet.

  • Instead of W-Compact, H-Regular for iPhone and W-Regular, H-Regular for iPad, I would suggest you to apply your constraint with W-Any, H-Any & View As should be : Generic. 屏幕截图
  • If you set W-Compact, H-Regular, the constraint applies to iPhone(Portrait) device.
  • If you set W-Regular, H-Regular, the constraint applies to iPad devices(Both Orientation).
  • If you set W-Any, H-Any, the constraint will be applied regardless of the device size and orientation.

To Center the logo, I would recommend 4 constraint to be set for the Logo.

  1. Width = Fix Width
  2. Height = Fix Height
  3. CenterX to Parent = 0
  4. CenterY to Parent = 0

-----or-----

  1. Top Space to Parent = 0
  2. Bottom Space to Parent = 0
  3. Leading Space to Parent = 0
  4. Trailing Space to Parent = 0

Set, UIImageView mode to Aspect Fit.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM