Ощущение естественности. Увеличьте масштаб приложения на острове Мауи.IOS

Программируем под IOS
Ответить
Anonymous
 Ощущение естественности. Увеличьте масштаб приложения на острове Мауи.

Сообщение Anonymous »

У меня есть щепотка, чтобы увеличить изображение. Хотя он и работает, он кажется неуклюжим и неестественным, особенно когда вы его панорамируете. Я не могу использовать контейнер панорамирования с функцией сжатия, так как мое решение использует для рисования одно касание, поэтому оно должно сохранять сжатие.
Повсюду есть примеры контейнеров сжатия от Microsoft, и независимо от того, как я его настраиваю, оно никогда не будет похоже на приложение для фотографий для iOS.
Я создал репозиторий в качестве примера приложения.
/>https://github.com/AustinOberholtzer/MauiPinchZoom
Будем очень благодарны за любую помощь!
public class PinchContainer : ContentView
{
private double currentScale = 1;
private double startScale = 1;
private double xOffset;
private double yOffset;

public PinchContainer()
{
var pinchGesture = new PinchGestureRecognizer();
pinchGesture.PinchUpdated += OnPinchUpdated;

GestureRecognizers.Add(pinchGesture);
}

private void OnPinchUpdated(object? sender, PinchGestureUpdatedEventArgs e)
{
if (e.Status == GestureStatus.Started)
{
startScale = Content.Scale;
Content.AnchorX = 0;
Content.AnchorY = 0;
}

if (e.Status == GestureStatus.Running)
{
// Calculate the scale factor to be applied.
currentScale += (e.Scale - 1) * startScale;
currentScale = Math.Max(1, currentScale);

// The ScaleOrigin is in relative coordinates to the wrapped user interface element,
// so get the X pixel coordinate.
var renderedX = Content.X + xOffset;
var deltaX = renderedX / Width;
var deltaWidth = Width / (Content.Width * startScale);
var originX = (e.ScaleOrigin.X - deltaX) * deltaWidth;

// The ScaleOrigin is in relative coordinates to the wrapped user interface element,
// so get the Y pixel coordinate.
var renderedY = Content.Y + yOffset;
var deltaY = renderedY / Height;
var deltaHeight = Height / (Content.Height * startScale);
var originY = (e.ScaleOrigin.Y - deltaY) * deltaHeight;

// Calculate the transformed element pixel coordinates.
var targetX = xOffset - ((originX * Content.Width) * (currentScale - startScale));
var targetY = yOffset - ((originY * Content.Height) * (currentScale - startScale));

// Apply translation based on the change in origin.
Content.TranslationX = Math.Clamp(targetX, -Content.Width * (currentScale - 1), 0);
Content.TranslationY = Math.Clamp(targetY, -Content.Height * (currentScale - 1), 0);

// Apply scale factor
Content.Scale = currentScale;
}

if (e.Status == GestureStatus.Completed)
{
// Store the translation delta's of the wrapped user interface element.
xOffset = Content.TranslationX;
yOffset = Content.TranslationY;
}
}
}
















Подробнее здесь: https://stackoverflow.com/questions/780 ... pplication
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»