在Xamarin表单应用程序中,如何在每次单击按钮时将图像旋转90度?
我正在使用插件。媒体从我的图库中选择照片。我想为用户提供一个选项,当他们点击图像时,可以旋转图像 使用“旋转”属性时,可以旋转图像一次。但是,每次用户单击按钮时,我都会将其旋转90度在Xamarin表单应用程序中,如何在每次单击按钮时将图像旋转90度?,xamarin,xamarin.forms,xamarin.android,xamarin.ios,Xamarin,Xamarin.forms,Xamarin.android,Xamarin.ios,我正在使用插件。媒体从我的图库中选择照片。我想为用户提供一个选项,当他们点击图像时,可以旋转图像 使用“旋转”属性时,可以旋转图像一次。但是,每次用户单击按钮时,我都会将其旋转90度 if (!CrossMedia.Current.IsPickPhotoSupported) { await DisplayAlert("Photos Not Supported", "Permission not granted
if (!CrossMedia.Current.IsPickPhotoSupported)
{
await DisplayAlert("Photos Not Supported", "Permission not granted
to photos", "OK");
return;
}
var file = Plugin.Media.CrossMedia.Current.PickPhotoAsync(new
Plugin.Media.Abstractions.PickMediaOptions
{
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small
});
if (file == null)
return;
imageProfile.Source = ImageSource.FromStream(() =>
{
var stream = file.Result.GetStream();
file.Result.Dispose();
return stream;
});
public void rotateButton_Clicked(object sender, Event args e) {
imageProfile.RotateX(90);
// This event allows me to rotate the image only once.
}
int angle = 0;
public void rotateButton_Clicked(object sender, Event args e) {
angle += 90;
imageProfile.RotateX(angle);
}