Avatar
Avatar

Reputation: 37

Cross compatible differences xamarin / C#

hope you can help!

Wondering how I can change code based on device version?

For example I have skia sharp code with a size integer set as below:

int size = Math.Min(180, 180);

On ios 13 this looks good but on ios 11 it's way too big!

How can I change the code behind size integer based on the ios version?

Thanks!

Upvotes: 1

Views: 191

Answers (2)

ColeX
ColeX

Reputation: 14475

For iOS

Just simply use UIDevice.CurrentDevice.CheckSystemVersion(13,0) .

It equals to @available(iOS 13, *) in Objective-C .

Refer to https://stackoverflow.com/a/21263587/8187800.

For forms

You can take a look at Xamarin.Essentials: Device Information .

// Operating System Version Number (7.0)
var version = DeviceInfo.VersionString;

Upvotes: 1

Vivek Nuna
Vivek Nuna

Reputation: 1

You can get the iOS version and based on it you can set the value accordingly.

string version = UIDevice.CurrentDevice.SystemVersion;

if(version == ……….

Upvotes: 0

Related Questions