UITableView custom header (like FoodSpotting app)

前端 未结 2 1922
滥情空心
滥情空心 2021-01-31 23:09

\"enter

Could somebody explain how this app (FoodSpotting), creates their custom section h

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 00:01

    I achieved the desired result in a different way. Instead of using tableView:viewForheaderInSection: (which doesn't work for me), I added an image view that holds the arrow image as a subview of the header view, and set the frame to be just below the header:

    // Inside HeaderView.m
    
    UIImageView *arrowImageView = [[UIImageView alloc] initWithImage:self.arrowImage];
    arrowImageView.frame = CGRectMake(arrowX, frame.size.height, self.arrowImage.size.width, self.arrowImage.size.height);
    [self addSubview:arrowImageView];
    [arrowImageView release];
    

    If you watch closely, there are two files (following-captionbubble-dark.png and following-captionbubble-dark@2x.png) in Foodspotting.app which look exactly like the arrow shown above in the question. So I guess they might have used a similar technique. Kudos to the Foodspotting team.

提交回复
热议问题