zoukankan      html  css  js  c++  java
  • UiPaged的自定义

    我们在写轮播图片时使用系统的控件往往无法满足项目需求,因此我们就开始自定义控件了。

    以下是UIPageControl的自定义:

    #import <UIKit/UIKit.h>

    @interface UPage : UIPageControl

    {

        UIImage *_activeImage;//(当前页面所表示图片)

        UIImage *_inactiveImage;//(当前界面外的图片)

    }

    @property(nonatomic,retain) UIImage *activeImage,*inactiveImage;

    @end

    #import "UPage.h"

    @implementation UPage

    @synthesize activeImage=_activeImage,inactiveImage=_inactiveImage;

    - (id)initWithFrame:(CGRect)frame

    {

        self = [super initWithFrame:frame];

        if (self)

        {

            // Initialization code

            self.activeImage = [UIImage imageNamed:@"sy_da_sdd.png"];//(当前页面所表示图片)

            self.inactiveImage = [UIImage imageNamed:@"sy_dt_sdde.png"];//(当前界面外的图片)

        }

        self.userInteractionEnabled=NO;

        return self;

    }

    - (void)updateDots

    {

        for (int i = 0; i< [self.subviews count]; i++)

        {

            if ([[[UIDevice currentDevice] systemVersion] floatValue]>= 7.0)

            {

                UIView *dot = [self.subviews objectAtIndex:i];

                if (i == self.currentPage)

                {

                    dot.layer.backgroundColor=[UIColor clearColor].CGColor;

                    dot.layer.contents=(id)self.activeImage.CGImage;

                }

                else

                {

                    dot.layer.backgroundColor=[UIColor clearColor].CGColor;

                    dot.layer.contents=(id)self.inactiveImage.CGImage;

                 }

            }

            else

            {

                UIImageView* dot = [self.subviews objectAtIndex:i];

                if (i == self.currentPage)

                {

                    dot.image = self.activeImage;

                }

                else

                {

                    dot.image = self.inactiveImage;

                }

            }

        }

    }

    - (void)setCurrentPage:(NSInteger)currentPage

    {

        [super setCurrentPage:currentPage];

        [self updateDots];

    }

    @end

  • 相关阅读:
    mvc get image 500
    git ssh 配置
    phpstorm及webstorm密钥
    HBuilder常用快捷键
    【wepy实战】wepy搭建完整项目
    【已解决】React中配置Sass引入.scss文件无效
    【微信小程序入门】微信小程序+和风天气完成天气预报
    浅析C#中的Lambda表达式
    C#中的委托(delegate)
    博客园第一天
  • 原文地址:https://www.cnblogs.com/anyezhuixing/p/3944272.html
Copyright © 2011-2022 走看看