Skip to content

Instantly share code, notes, and snippets.

@amay077
Last active September 8, 2017 10:20
Show Gist options
  • Select an option

  • Save amay077/6062566 to your computer and use it in GitHub Desktop.

Select an option

Save amay077/6062566 to your computer and use it in GitHub Desktop.
Xamarin.iOS で、スワイプで View を切り替える方法 ref: http://qiita.com/amay077/items/0a79ef6f091f17ff0fe9
public override void ViewDidLoad()
{
base.ViewDidLoad();
SizeF imageSize = new SizeF(320f, 460f);
for (int i = 0; i < 3; i++)
{
var image = UIImage.FromFile(String.Format("image{0}.png", i));
var imgView = new UIImageView(image);
// x方向にずらしながら…
imgView.Frame = new RectangleF(imageSize.Width * i, 0f,
imageSize.Width, imageSize.Height);
// 子として追加。
scrollView.AddSubview(imgView);
}
// スクロール可能領域を設定する
scrollView.ContentSize = new SizeF(imageSize.Width * 3, imageSize.Height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment