Random color for uiview

Viewed 6869

In my xcode i have a uiview which is dynamic

UIView *gaping=[[UIView alloc] initWithFrame:CGRectMake(15, 0, 172, 39)];
    gaping.backgroundColor= [UIColor redColor];

I need the background color to be dynamically change.

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UIView *gaping=[[UIView alloc] initWithFrame:CGRectMake(15, 0, 172, 39)];
    gaping.backgroundColor= [UIColor redColor];


    UITableViewCell *TableCell = [[UITableViewCell alloc] init];
    NSMutableDictionary *RRTYRT = [DATAARRAY objectAtIndex:indexPath.row];

    UILabel *LabelOne = [[UILabel alloc] initWithFrame:CGRectMake(45, 0, 100, 30)];
    LabelOne.textColor = [UIColor whiteColor];
    LabelOne.backgroundColor = [UIColor clearColor];
    LabelOne.text = [RRTYRT objectForKey:@"themename"];
    [gaping addSubview:LabelOne];

    [gaping.layer setCornerRadius:5.8f];

    [TableCell.contentView addSubview:gaping];
    return TableCell;

}

The below mentioned code is the table view within which i have this view and for each cell of the tableview i need to change the color of this UiView. I know its a bit confusing to understand so please if anyone can help me it would be aooritiable .

Thanks

7 Answers
Related