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


C# UISlider.AddTarget方法代码示例

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


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

示例1: LoadContent

        public void LoadContent()
        {
            this.BackgroundColor = UIColor.Clear;
            this.UserInteractionEnabled = true;

            if (_label == null || _slider == null)
            {
                /*foreach (UIView subview in this.Subviews)
                {
                    subview.PerformSelector(new MonoTouch.ObjCRuntime.Selector("removeFromSuperview"), subview, 0);
                }*/

                _label = new MBSliderLabel(RectangleF.Empty);
                _label.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                _label.TextColor = UIColor.White;
                _label.TextAlignment = UITextAlignment.Center;
                _label.BackgroundColor = UIColor.Clear;
                _label.Font = UIFont.SystemFontOfSize(24);
                _label.Text = "Slide";
                this.AddSubview(_label);
                _label.Animated = true;

                _slider = new UISlider(RectangleF.Empty);
                _slider.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
                PointF ctr = _slider.Center;
                RectangleF sliderFrame = _slider.Frame;
                sliderFrame.Width -= 4; //each "edge" of the track is 2 pixels wide
                _slider.Frame = sliderFrame;
                _slider.Center = ctr;
                _slider.BackgroundColor = UIColor.Clear;
                UIImage thumbImage = this.ThumbWithColor(UIColor.FromRGBA(200, 200, 200, 1));
                _slider.SetThumbImage(thumbImage, UIControlState.Normal);

                UIImage clearImage = this.ClearPixel();
                _slider.SetMaxTrackImage(clearImage, UIControlState.Normal);
                _slider.SetMinTrackImage(clearImage, UIControlState.Normal);

                _slider.MinValue = 0.0f;
                _slider.MaxValue = 1.0f;
                _slider.Continuous = true;
                _slider.Value = 0.0f;
                this.AddSubview (_slider);

                // Set the slider action methods
                _slider.AddTarget (sliderUp, UIControlEvent.TouchUpInside);
                _slider.AddTarget (sliderUp, UIControlEvent.TouchUpOutside);
                _slider.AddTarget (sliderDown, UIControlEvent.TouchDown);
                _slider.AddTarget (sliderChanged, UIControlEvent.ValueChanged);
            }
        }
开发者ID:RTodorov,项目名称:MBSliderView-Xamarin-iOS,代码行数:50,代码来源:MBSliderView.cs


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