zoukankan      html  css  js  c++  java
  • 重写pageControl更改滑动点的样式

    #import <UIKit/UIKit.h>
    
    
    @interface YS_PageControl : UIPageControl
    @end
    //////////////////////////////////
    
    #import "YS_PageControl.h"
    
    
    @implementation YS_PageControl
    
    //@synthesize activeImage;
    //@synthesize inactiveImage;
    
    - (id)initWithFrame:(CGRect)frame {
        
        self = [super initWithFrame:frame];
        if (self) {
        }
        return self;
    }
    
    -(void) updateDots //通过便利子视图的数组更改选中或未选中的图片
    {
        for (int i = 0; i < [self.subviews count]; i++)
        {
            UIImageView *dot = [self.subviews objectAtIndex:i];//需要学习的东西
            CGPoint cen = dot.center;
            dot.frame = CGRectMake(0, 0, 7, 7);
            if (i == self.currentPage) { 
                dot.image = [UIImage imageNamed:@"绿点.png"];
            }
            else{
                dot.image = [UIImage imageNamed:@"黑点.png"];
            }
            dot.center = cen;
        }
    }
    
    -(void) setCurrentPage:(NSInteger)page  //重写pageControl的currentPage
    {
        [super setCurrentPage:page];
        [self updateDots];
    }
    
    - (void)dealloc {
        [super dealloc];
    }
    
    
    @end
  • 相关阅读:
    elasticsearch api
    kaili camera
    mysql create db utf8 character
    npm run-script
    d-link kvm 关闭声音
    setInterval js
    jpa datasource config
    mvn添加本地jar
    Sublime Text 2 中文包
    初遇ping++
  • 原文地址:https://www.cnblogs.com/leevaboo/p/2849389.html
Copyright © 2011-2022 走看看