Search code examples
iosxcodehud

Input Letter in rectangle drawing ios


I'm drawing three rectangles in order to show the loading, however I want to input Alphabets in those rectangles, how can I put letters in that.

My Function:

- (void)configUI {
    self.backgroundColor = [UIColor clearColor];

    UIView *rect1 = [self drawRectAtPosition:CGPointMake(0, 0)];
    UIView *rect2 = [self drawRectAtPosition:CGPointMake(20, 0)];
    UIView *rect3 = [self drawRectAtPosition:CGPointMake(40, 0)];

    [self addSubview:rect1];
    [self addSubview:rect2];
    [self addSubview:rect3];

    [self doAnimateCycleWithRects:@[rect1, rect2, rect3]];
}

I want to insert the letter "A" in rect1, "B" in rect2 and "C" in rect3.


Solution

  • Use UILabel instead of UIView. Set the label text. (Note that a UILabel has a background color just like a UIView.)