3

We have page control width 100 but then also it is going in weird manner

enter image description here

Please help how to handle its width

Edit:

[pageControl setFrame:CGRectMake(100,258,100,10)];

This is how i have set frame.I have cross checked no other place i am changing frame. Number of pages are dynamic Whole setting i have done by coding NOT interface builder

4

4 回答 4

2

在方法中尝试这一行,viewDidLoad:并在将页面分配给该控件后编写此代码......

 yourPageControl.autoresizingMask = UIViewAutoresizingFlexibleWidth;

并且对于 PageControl align center 使用波纹管...

yourPageControl.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin;

您也可以从 Interface Builder 进行此设置

更新:

//use this code instead of your for init UIPageControl
pageControl = [[UIPageControl alloc] init];
pageControl.frame = CGRectMake(100,258,100,10);
pageControl.numberOfPages = 2;//set here pages which you want..
pageControl.currentPage = 0;
pageControl.autoresizingMask = UIViewAutoresizingNone;
[self.view addSubview:pageControl];
于 2013-04-10T05:01:37.373 回答
2

我为时已晚,但仍然,试试下面的代码,它会将点限制在页面控件的范围内

pageControl = [[UIPageControl alloc] init];
pageControl.frame = CGRectMake(100,258,100,10);
pageControl.numberOfPages = 100;
pageControl.currentPage = 0;
pageControl.clipsToBounds = YES;
[self.view addSubview:pageControl];

在这里,您可以看到边界内的点。

于 2014-10-17T06:43:47.467 回答
1

只需将属性“clipsToBounds”设置为 true。

于 2017-05-22T10:11:00.253 回答
0

我如何解决: 将宽度从高度加倍

pageControl.transform = CGAffineTransform(scaleX: 2, y: 1)


 pageControl.clipsToBounds = true
于 2020-08-20T11:54:35.367 回答