Showing posts with label Label related.... Show all posts
Showing posts with label Label related.... Show all posts

29 Sept 2017

How to set different colour Font text to single Label(Attributed Text)...



How to set different colour Font text to single Label(Attributed Text)...



-(NSAttributedString *)AttrStr:(NSString *)str1 fontString:(NSString *)str2 {
    
    NSDictionary *dict1;
    NSDictionary *dict2;
    
    dict1 = @{NSFontAttributeName:[UIFont fontWithName:promptLight size:10.0],NSForegroundColorAttributeName:[UIColor colorWithRed:127/255.0 green:127/255.0 blue:127/255.0 alpha:1.0]};
    dict2 = @{NSFontAttributeName:[UIFont fontWithName:promptLight size:10.0],NSForegroundColorAttributeName:[UIColor colorWithRed:78/255.0 green:186/255.0 blue:222/255.0 alpha:1.0]};
    
    NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] init];
    [attString appendAttributedString:[[NSAttributedString alloc] initWithString:str1    attributes:dict1]];
    [attString appendAttributedString:[[NSAttributedString alloc] initWithString:str2   attributes:dict2]];
    
    return attString;

}




cell.LSALbl.attributedText =  [self AttrStr:@"LSA: " fontString:[NSString stringWithFormat:@"%ld",lroundf([_productionDataObj.lsaPlanned floatValue])]];

25 Mar 2017

How to create a basic UIButton, UILabel Programmatically...




How to create a basic UIButton, UILabel Programmatically...


  /*================ UIButton has different ButtonTypes ================ */ 

    self.system=[UIButton buttonWithType:UIButtonTypeSystem];
    self.system.frame=CGRectMake(80, 220, 100, 100);
//    self.system.backgroundColor=[UIColor cyanColor];
    [self.system setTitle:@"SystemBtn" forState:UIControlStateNormal];
    self.system.layer.cornerRadius = 50;
    self.system.backgroundColor=[UIColor colorWithRed:0.5 green:1 blue:0.6 alpha:0.8];
    [self.system setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    self.system.tag=4;
    
    [self.system addTarget:self action:@selector(buttonsAction1:) forControlEvents:UIControlEventTouchCancel];


 /*==================== Label ===================== */


    self.onLabel=[[UILabel alloc]init];
    self.onLabel.frame=CGRectMake(20, 400, 380, 100);
    self.onLabel.backgroundColor=[UIColor lightGrayColor];
    self.onLabel.textAlignment=1;
    self.onLabel.font=[UIFont fontWithName:@"Arial" size:36];
    self.onLabel.textColor=[UIColor redColor];
    [self.view addSubview:self.onLabel];

-(void)buttonsAction1:(UIButton *)sender
{
    self.onLabel.text=[NSMutableString stringWithFormat:@" %ld ",(long)sender.tag];
    self.label.text=@"TouchUpInside";
    
}

Recent Posts

Codable demo

Link: https://www.dropbox.com/s/kw7c1kgv1628bh7/codableDemo.zip?dl=0