Customize the startup loading page for an iOS Mini Program

更新时间:
复制 MD 格式

When a Mini Program starts, the container displays a loading page if the program is not yet on the device. The user waits while the Mini Program installs. After the installation is complete, the loading page closes, and the Mini Program opens.

启动加载项

Implement a custom loading page

For iOS Mini Programs, mPaaS lets you customize the content of the loading page. Follow these steps to configure the page:

  1. Create a child class that inherits from APBaseLoadingView to define your custom loading page view. In this class, modify the style of the view.

    subclass

    The following code is an example:

     @interface MPBaseLoadingView : APBaseLoadingView
    
     @end
    
     @implementation MPBaseLoadingView
    
     - (instancetype)init
     {
         self = [super init];
         if (self) {
             self.backgroundColor = [UIColor grayColor];
             self.titleLabel.backgroundColor = [UIColor redColor];
             self.titleLabel.font = [UIFont boldSystemFontOfSize:8];
    
             self.iconImageView.backgroundColor = [UIColor blueColor];
    
             self.pageControl.backgroundColor = [UIColor orangeColor];
    
         }
    
         return self;
     }
    
     - (void)layoutSubviews
     {
         [super layoutSubviews];
         // Adjust the position of the view
    
         CGSize size  = self.bounds.size;
         CGRect frame = CGRectMake((size.width - 80)/2, 0, 80, 80);
         self.iconImageView.frame = frame;
    
         frame = CGRectMake(15, CGRectGetMaxY(self.iconImageView.frame) + 6, size.width - 30, 22);
         self.titleLabel.frame = frame;
    
         frame = CGRectMake((size.width-40)/2, CGRectGetMaxY(self.titleLabel.frame) + 21, 40, 20);
         self.pageControl.frame = frame;
     }
    
     @end
  2. In the category for the DTFrameworkInterface class, override the baseloadViewClass method to return the class name of your custom loading page view.

     - (NSString *)baseloadViewClass
     {
         return @"MPBaseLoadingView";
     }