monotouch中UIPageControl的使用
2013-12-09 16:24
260 查看
UIPageControl类似web中的幻灯片,手动触发可以切换视图(界面),当然可以用NSTimer来控制自动切换。看代码:
using System; // using System.Drawing; using MonoTouch.UIKit; using System.Collections.Generic; namespace GCForum { public class PagingController : UIViewController { public PagingController () { } UIScrollView _scroll; List<UIView> _pages; UIPageControl _pager; int _numPages=4; //总共有几页 float _padding=10; float _pageHeight=380; float _pageWidth=300; public override void ViewDidLoad () { base.ViewDidLoad (); View.BackgroundColor = UIColor.Black; _pages = new List<UIView> (); _scroll = new UIScrollView { Frame = this.View.Frame, PagingEnabled = true, ContentSize = new SizeF(_numPages * ( _pageWidth + 2 * _padding), this.View.Frame.Height) }; this.View.AddSubview (_scroll); for (int i = 0; i < _numPages; i++) { UIView v = new UIView (); v.Add( new UILabel{ Frame = new RectangleF (100, 50, 100, 25), Text = String.Format("Page {0}", i+1)} ); _pages.Add (v); v.BackgroundColor = UIColor.LightGray; v.Frame = new RectangleF ( i * + _pageWidth + _padding + (2 * _padding * i), 0, _pageWidth, _pageHeight); _scroll.AddSubview (v); } _scroll.Scrolled += delegate { _pager.CurrentPage = (int)Math.Round (_scroll.ContentOffset.X / _pageWidth); }; _pager = new UIPageControl (); _pager.Pages = _numPages; _pager.Frame = new RectangleF (0, 420, View.Frame.Width, 50); this.View.AddSubview (_pager); } //... } }
相关文章推荐
- UIScrollView,UIPageControl的结合使用
- iOS UIPageControl使用
- UIScrollView + UIPageControl的使用
- UIScrollView UIPageControl 的使用
- iOS—UIPageControl的使用
- UIPageControl . UIScrollView UIPageControl 与 UIScrollView 的结合使⽤用
- iOS UIPageControl使用
- UIPageControl  和 UISrollView 使用
- iOS--UIScrollView和UIPageControl配合使用完成引用介绍页面
- UI UIScrollView和UIPageControl的结合使用
- IOS--UIScrollView和UIPageControl配合使用
- UIPageControl+UIScrollView的简单使用
- [IOS]使用UIScrollView和UIPageControl显示半透明帮助蒙板
- IOS UI UIScrollView+UIPageControl组合使用
- UIPageControl的使用
- C# iphone MontTouch UIPageControl 的使用
- UIPageControl简单使用
- UIScrollView&UIPageControl的使用
- iOS UIPageControl使用
- iOS --- UIScrollView和UIPageControl的简单使用