当前位置: 首页>>代码示例>>C#>>正文


C# UIScrollView.AddObserver方法代码示例

本文整理汇总了C#中UIScrollView.AddObserver方法的典型用法代码示例。如果您正苦于以下问题:C# UIScrollView.AddObserver方法的具体用法?C# UIScrollView.AddObserver怎么用?C# UIScrollView.AddObserver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIScrollView的用法示例。


在下文中一共展示了UIScrollView.AddObserver方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ODRefreshControl

    public ODRefreshControl (UIScrollView scrollView, ODRefreshControlLayout layout = ODRefreshControlLayout.Vertical, UIView activity = null)
        : base (
            (layout == ODRefreshControlLayout.Vertical)
            ? new RectangleF (0, (-TotalViewHeight - scrollView.ContentInset.Top), scrollView.Bounds.Width, TotalViewHeight)
            : new RectangleF ((-TotalViewHeight - scrollView.ContentInset.Left), 0, TotalViewHeight, scrollView.Bounds.Height)
            )
    {
        ScrollView = scrollView;
        OriginalContentInset = scrollView.ContentInset;

        _vertical = (layout == ODRefreshControlLayout.Vertical);

        AutoresizingMask = (_vertical)
            ? UIViewAutoresizing.FlexibleWidth
            : UIViewAutoresizing.FlexibleHeight;
        
        ScrollView.AddSubview (this);
        ScrollView.AddObserver (this, new NSString ("contentOffset"), NSKeyValueObservingOptions.New, IntPtr.Zero);
        ScrollView.AddObserver (this, new NSString ("contentInset"), NSKeyValueObservingOptions.New, IntPtr.Zero);
        
        _activity = activity ?? new UIActivityIndicatorView (UIActivityIndicatorViewStyle.Gray);
        _activity.Center = new PointF ((float) Math.Floor (Bounds.Width / 2.0f), (float) Math.Floor (Bounds.Height / 2.0f));
        
        _activity.AutoresizingMask = (_vertical)
            ? UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin
            : UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin;
        
        _activity.Alpha = 1;
        
        if (_activity is UIActivityIndicatorView) {
            ((UIActivityIndicatorView) _activity).StartAnimating ();
        }
        AddSubview (_activity);
        
        _refreshing = false;
        _canRefresh = true;
        
        _ignoreInset = false;
        _ignoreOffset = false;
        _didSetInset = false;
        _hasSectionHeaders = false;

        _tintColor = UIColor.FromRGB (155, 162, 172);
        _shadowColor = UIColor.Black;
        _highlightColor = UIColor.White.ColorWithAlpha (.2f);

        _shapeLayer = new CAShapeLayer {
            FillColor = _tintColor.CGColor,
            StrokeColor = UIColor.DarkGray.ColorWithAlpha (.5f).CGColor,
            LineWidth = .5f,
            ShadowColor = _shadowColor.CGColor,
            ShadowOffset = new SizeF (0, 1),
            ShadowOpacity = .4f,
            ShadowRadius = .5f
        };
        
        Layer.AddSublayer (_shapeLayer);
        
        _arrowLayer = new CAShapeLayer {
            StrokeColor = UIColor.DarkGray.ColorWithAlpha (.5f).CGColor,
            LineWidth = .5f,
            FillColor = UIColor.White.CGColor
        };
        
        _shapeLayer.AddSublayer (_arrowLayer);

        _highlightLayer = new CAShapeLayer {
            FillColor = _highlightColor.CGColor
        };

        _shapeLayer.AddSublayer (_highlightLayer);

        if (!_vertical) {
            // Highlight layer is currently not shown in horizontal mode
            // because it has a wrong path.

            // It should instead be drawn all the way from left to right circle.
            // Feel free to work on it!

            _highlightLayer.RemoveFromSuperLayer ();
        }
    }
开发者ID:stampsy,项目名称:MonoTouch.ODRefreshControl,代码行数:82,代码来源:ODRefreshControl.cs


注:本文中的UIScrollView.AddObserver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。