kresowa 2016-01-12 03:08 采纳率: 0%
浏览 2147

UIPageControl无法正常显示

UIScrollView * scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT * 0.35)];
[self addSubview:scrollView];
self.scrollView = scrollView;

for (int i = 0; i < 6; i++) {
    UIImageView * imageViwe = [[UIImageView alloc] initWithFrame:CGRectMake(scrollView.width * i, 0, WIDTH, scrollView.height)];

    NSString * name = [NSString stringWithFormat:@"00%d",i+1];
    imageViwe.image = [UIImage imageNamed:name];
    [scrollView addSubview:imageViwe];
}

scrollView.contentSize = CGSizeMake(WIDTH * 6, 0);
scrollView.pagingEnabled = YES;
scrollView.bounces = NO;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.delegate = self;

//透明栏
UIView * backView = [[UIView alloc] initWithFrame:CGRectMake(0, scrollView.height - 30, WIDTH, 30)];
backView.backgroundColor = MZMCOLOR(0, 0, 0, 0.2);
[self addSubview:backView];

UILabel * nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5, WIDTH - 100, 20)];
nameLabel.text = @"balabla";
nameLabel.font = [UIFont systemFontOfSize:15];
nameLabel.textColor = [UIColor whiteColor];
nameLabel.textAlignment = NSTextAlignmentLeft;
[backView addSubview:nameLabel];

//分页控制
UIPageControl * pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(WIDTH - 80, 5, WIDTH, 20)];
pageControl.numberOfPages = 6;
pageControl.pageIndicatorTintColor = [UIColor whiteColor];
pageControl.currentPageIndicatorTintColor = MZMColor;
pageControl.backgroundColor = [UIColor redColor];
pageControl.currentPage = 0;
[backView addSubview:pageControl];
self.pageControl = pageControl;

    代码如上所示  但是显示出来的UIPageControl只有一个点求大大们帮忙看看![图片说明](https://img-ask.csdn.net/upload/201601/12/1452568080_743907.png)
  • 写回答

1条回答 默认 最新

  • oyljerry 2016-01-12 03:27
    关注

    这个要看一下控件的constrains,它会收到父view的限制,你需要设置好。

    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗