UIPageControl - How to make the background transparent?

后端 未结 8 2683
無奈伤痛
無奈伤痛 2021-02-18 21:30

I am using UIPageControl and trying to make the background transparent.

UIPageControl *pageControl = [UIPageControl appearance];
pageControl.pageInd         


        
8条回答
  •  天涯浪人
    2021-02-18 22:12

    Page control is transparent by default.

    Check with this sample code:

    UIPageControl *pageControl = [[UIPageControl alloc] init];
    pageControl.frame = CGRectMake(10,10,100,100);
    pageControl.numberOfPages = 8;
    pageControl.currentPage = 0;
    [self.view addSubview:pageControl];
    [self.view bringSubviewToFront:pageControl];
    [self.view setBackgroundColor:[UIColor blackColor]];
    

    Please find the more customization possibilities below

    Appearance of Page Controls

    You can customize the appearance of a page control by setting the properties depicted below.

    enter image description here

    To customize the appearance of all page controls in your app, use the appearance proxy (for example, [UIPageControl appearance]). For more information about appearance proxies, see Appearance Proxies.

    Tint Color

    The only way to customize the appearance of a page control is by setting custom tints for the dots representing each page. The Current Page (currentPageIndicatorTintColor) field affects the color of the dot representing the currently displayed page, and the Tint Color (pageIndicatorTintColor) field affects the color of the dots representing every other page. The default color is white for the current page dot, and translucent gray for the other page dots.

    enter image description here

    If you want your custom colors to be translucent, you must specify a color with an alpha value of less than 1.0. This must be done programmatically, as in the following example:

    self.myPageControl.currentPageIndicatorTintColor = [UIColor colorWithRed:0.0 green:0.0 blue:1.0 alpha:0.5];
    self.myPageControl.pageIndicatorTintColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.5];
    

    Check more details in UIPageControl - Developer.Apple documentation

提交回复
热议问题