IOS is similar to the Netease news homepage news carousel component.
Requirement Analysis 1. News images can be rolled horizontally and cyclically. 2. News Titles are displayed when the corresponding images are rolled. 3. Each news image can be clicked. 4. pageControl tip. 5. Control scalability ii. Design and Implementation 1. Use SDWebImage third-party library to display images, cache images, asynchronously load images through URLs 2. Use a horizontal scroll UITableView to achieve circular scrolling 3. Use a black translucent background and a white text UILabel to display Titles 4. Define each news data structure: /** @ brief uses the local address by default. If not, use the network image */@ interface PhotoNewsModel: NSObject/** @ image displayed during brief loading */@ property (nonatomic, strong) UIImage * loadingImage;/** @ brief image local address */@ property (nonatomic, strong) NSString * localPath;/** @ brief news image address */@ property (nonatomic, strong) NSString * photoUrl; /** @ brief news title */@ property (nonatomic, strong) NSString * title; @ end5, proxy protocol: @ protocol UIPhotoNewsViewDelegate <NSObject>/*** obtain the number of image news items ** @ param photoNews control ** @ return the number of image news items */-(NSUInteger) photoNewsCount :( UIPhotoNewsView *) photoNews; /*** return the model of the first image news ** @ param photoNews control * @ param index ** @ return returns the model */-(PhotoNewsModel *) that describes the image news *) photoNews :( UIPhotoNewsView *) photoNews photoModelAtIndex :( NSUInteger) index; /*** callback of image news click ** @ param photoNews control * @ param model click the model corresponding to the news */-(void) photoNews :( UIPhotoNewsView *) photoNews photoDidClick :( PhotoNewsModel *) model; @ end6. How to Implement Circular scrolling?) copy a copy of the data to be displayed, which is equivalent to 1, 2, 3, 4 | 1, 2, 3, and 4 B). When initializing the data, locate the second copy. Here c) when you scroll to the previous 1 or 2, set to jump to the second 1 and 2 d) key code:-(void) makeCycleScroll {if (self. realCount> = 2) {CGFloat currentOffsetX = self. contentTableView. contentOffset. x; CGFloat currentOffSetY = self. contentTableView. contentOffset. y; CGFloat contentHeight = self. contentTableView. contentSize. height; if (currentOffSetY <(contentHeight/8.0) {self. contentTableView. contentOffset = CGPointMake (currentOffsetX, (currentOffSetY + (contentHeight/2);} if (currentOffSetY> = (contentHeight * 6)/8.0) {self. contentTableView. contentOffset = CGPointMake (currentOffsetX, (currentOffSetY-(contentHeight/2 )));}}}