// модифицированный код
// вы можете создать все с вашим собственным. Это очень простой способ использования swreveal. Надеюсь, это будет полезно.
NSArray *menuItems;
menuItems = @[@"title",@"Edit Profile",@"Match",@"Add Event",@"Give",@"Events",@"Market place",@"Recognizes businesses",@"About",@"Termsnuse",@"changePassword",@"Logout"];
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [menuItems count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [menuItems objectAtIndex:indexPath.row];
UIImageView*imgProfile=[[UIImageView alloc]initWithFrame:CGRectMake(10, 20, 50, 50)];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = Black;
[cell setSelectedBackgroundView:bgColorView];
if (indexPath.row==0) {
UILabel*lbl;
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 130)];
UILabel*lblUserName;
UIImageView*imgUser;
imgUser=[[UIImageView alloc]initWithFrame:CGRectMake(100, 10, 80, 80)];
lblUserName=[[UILabel alloc]initWithFrame:CGRectMake(40, 95, 200, 30)];
lbl.backgroundColor=Black;
imgProfile.backgroundColor=[UIColor orangeColor];
NSUserDefaults*defaults=[NSUserDefaults standardUserDefaults];
NSDictionary *dict = [defaults objectForKey:@"Ucountry"];
NSString *strImage = [dict objectForKey:@"image"];
if ([strImage isEqualToString:@""]) {
NSLog(@"strImage====>%@",strImage);
// strImage = [strImage stringByReplacingOccurrencesOfString:@" " withString:@""];
// NSURL *imageURL = [[NSURL alloc]initWithString:strImage];
// [imgUser sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"user"]];
}else{
strImage = [strImage stringByReplacingOccurrencesOfString:@" " withString:@""];
NSURL *imageURL = [[NSURL alloc]initWithString:strImage];
[imgUser sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"user"]];
}
imgUser.layer.cornerRadius=40;
imgUser.clipsToBounds=YES;
imgUser.layer.borderWidth=2.0f;
imgUser.layer.borderColor=bgColor.CGColor;
//imgUser.image=[UIImage imageNamed:@"welcome_rabecca"];
NSString *strFullName =[dict objectForKey:@"firstName"];
lblUserName.text=strFullName;
lblUserName.textColor=White;
lblUserName.textAlignment=NSTextAlignmentCenter;
lblUserName.font=[UIFont fontWithName:@"Kiro" size:14];
lblUserName.backgroundColor=Black;
[cell addSubview:lbl];
[cell addSubview:imgUser];
[cell addSubview:lblUserName];
}
else if (indexPath.row==1)
{
UILabel*lbl;
UILabel*lbln;
UIImageView*img;
img=[[UIImageView alloc]initWithFrame:CGRectMake(8, 12, 20, 20)];
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
lbln=[[UILabel alloc]initWithFrame:CGRectMake(47, 0, 320, 44)];
lbl.backgroundColor=Black;
lbl.layer.borderWidth=1.0f;
lbl.layer.borderColor=bgColor.CGColor;
[email protected]"Edit Profile";
lbln.textColor=White;
lbln.font=[UIFont fontWithName:@"Kiro" size:18];
img.image=[UIImage imageNamed:@"edit"];
[cell addSubview:lbl];
[cell addSubview:lbln];
[cell addSubview:img];
}
else if (indexPath.row==2)
{
UILabel*lbl;
UILabel*lbln;
UIImageView*img;
img=[[UIImageView alloc]initWithFrame:CGRectMake(8, 12, 20, 20)];
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
lbln=[[UILabel alloc]initWithFrame:CGRectMake(47, 0, 320, 44)];
lbl.backgroundColor=Black;
lbl.layer.borderWidth=1.0f;
lbl.layer.borderColor=bgColor.CGColor;
[email protected]"Match a Friend";
lbln.textColor=White;
lbln.font=[UIFont fontWithName:@"Kiro" size:18];
img.image=[UIImage imageNamed:@"match"];
[cell addSubview:lbl];
[cell addSubview:lbln];
[cell addSubview:img];
}
else if (indexPath.row==3)
{
UILabel*lbl;
UILabel*lbln;
UIImageView*img;
img=[[UIImageView alloc]initWithFrame:CGRectMake(8, 12, 20, 20)];
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
lbln=[[UILabel alloc]initWithFrame:CGRectMake(47, 0, 320, 44)];
lbl.backgroundColor=Black;
lbl.layer.borderWidth=1.0f;
lbl.layer.borderColor=bgColor.CGColor;
[email protected]"Post Charity Events";
lbln.textColor=White;
lbln.font=[UIFont fontWithName:@"Kiro" size:18];
img.image=[UIImage imageNamed:@"addevent"];
[cell addSubview:lbl];
[cell addSubview:lbln];
[cell addSubview:img];
}
else if (indexPath.row==4)
{
UILabel*lbl;
UILabel*lbln;
UIImageView*img;
img=[[UIImageView alloc]initWithFrame:CGRectMake(8, 12, 20, 20)];
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
lbln=[[UILabel alloc]initWithFrame:CGRectMake(47, 0, 320, 44)];
lbl.backgroundColor=Black;
lbl.layer.borderWidth=1.0f;
lbl.layer.borderColor=bgColor.CGColor;
[email protected]"Give to Causes";
lbln.textColor=White;
lbln.font=[UIFont fontWithName:@"Kiro" size:18];
img.image=[UIImage imageNamed:@"give"];
[cell addSubview:lbl];
[cell addSubview:lbln];
[cell addSubview:img];
} else if (indexPath.row==5)
{
UILabel*lbl;
UILabel*lbln;
UIImageView*img;
img=[[UIImageView alloc]initWithFrame:CGRectMake(8, 12, 20, 20)];
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
lbln=[[UILabel alloc]initWithFrame:CGRectMake(47, 0, 320, 44)];
lbl.backgroundColor=Black;
lbl.layer.borderWidth=1.0f;
lbl.layer.borderColor=bgColor.CGColor;
[email protected]"Events";
lbln.textColor=White;
lbln.font=[UIFont fontWithName:@"Kiro" size:18];
img.image=[UIImage imageNamed:@"event"];
[cell addSubview:lbl];
[cell addSubview:lbln];
[cell addSubview:img];
} else if (indexPath.row==6) {
UILabel*lbl;
UILabel*lbln;
UIImageView*img;
img=[[UIImageView alloc]initWithFrame:CGRectMake(8, 12, 20, 20)];
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
lbln=[[UILabel alloc]initWithFrame:CGRectMake(47, 0, 320, 44)];
lbl.backgroundColor=Black;
lbl.layer.borderWidth=1.0f;
lbl.layer.borderColor=bgColor.CGColor;
[email protected]"Market Place";
lbln.textColor=White;
lbln.font=[UIFont fontWithName:@"Kiro" size:18];
img.image=[UIImage imageNamed:@"market"];
[cell addSubview:lbl];
[cell addSubview:lbln];
[cell addSubview:img];
}
else if (indexPath.row==7) {
UILabel*lbl;
UILabel*lbln;
UIImageView*img;
img=[[UIImageView alloc]initWithFrame:CGRectMake(8, 12, 20, 20)];
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
lbln=[[UILabel alloc]initWithFrame:CGRectMake(47, 0, 320, 44)];
lbl.backgroundColor=Black;
lbl.layer.borderWidth=1.0f;
lbl.layer.borderColor=bgColor.CGColor;
[email protected]"Promote Your Business";
lbln.textColor=White;
lbln.font=[UIFont fontWithName:@"Kiro" size:18];
img.image=[UIImage imageNamed:@"market"];
[cell addSubview:lbl];
[cell addSubview:lbln];
[cell addSubview:img];
}
else if (indexPath.row==8) {
UILabel*lbl;
UILabel*lbln;
UIImageView*img;
img=[[UIImageView alloc]initWithFrame:CGRectMake(8, 12, 20, 20)];
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
lbln=[[UILabel alloc]initWithFrame:CGRectMake(47, 0, 320, 44)];
lbl.backgroundColor=Black;
lbl.layer.borderWidth=1.0f;
lbl.layer.borderColor=bgColor.CGColor;
[email protected]"About";
lbln.textColor=White;
lbln.font=[UIFont fontWithName:@"Kiro" size:18];
img.image=[UIImage imageNamed:@"about"];
[cell addSubview:lbl];
[cell addSubview:lbln];
[cell addSubview:img];
}
else if (indexPath.row==9) {
UILabel*lbl;
UILabel*lbln;
UIImageView*img;
img=[[UIImageView alloc]initWithFrame:CGRectMake(8, 12, 20, 20)];
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
lbln=[[UILabel alloc]initWithFrame:CGRectMake(47, 0, 320, 44)];
lbl.backgroundColor=Black;
lbl.layer.borderWidth=1.0f;
lbl.layer.borderColor=bgColor.CGColor;
[email protected]"Terms of Use";
lbln.textColor=White;
lbln.font=[UIFont fontWithName:@"Kiro" size:18];
img.image=[UIImage imageNamed:@"term"];
[cell addSubview:lbl];
[cell addSubview:lbln];
[cell addSubview:img];
}
else if (indexPath.row==10){
UILabel*lbl;
UILabel*lbln;
UIImageView*img;
img=[[UIImageView alloc]initWithFrame:CGRectMake(8, 12, 20, 20)];
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
lbln=[[UILabel alloc]initWithFrame:CGRectMake(47, 0, 320, 44)];
lbl.backgroundColor=Black;
lbl.layer.borderWidth=1.0f;
lbl.layer.borderColor=bgColor.CGColor;
[email protected]"Change Password";
lbln.textColor=White;
lbln.font=[UIFont fontWithName:@"Kiro" size:18];
img.image=[UIImage imageNamed:@"changePassword"];
[cell addSubview:lbl];
[cell addSubview:lbln];
[cell addSubview:img];
} else if (indexPath.row==11){
UILabel*lbl;
UILabel*lblLine;
UILabel*lbln;
UIImageView*img;
img=[[UIImageView alloc]initWithFrame:CGRectMake(8, 12, 20, 20)];
lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
lbln=[[UILabel alloc]initWithFrame:CGRectMake(47, 0, 320, 44)];
lblLine=[[UILabel alloc]initWithFrame:CGRectMake(0, 39, 320, 1)];
lblLine.backgroundColor=bgColor;
lbl.backgroundColor=Black;
lbl.layer.borderWidth=1.0f;
lbl.layer.borderColor=bgColor.CGColor;
[email protected]"Logout";
lbln.textColor=White;
lbln.font=[UIFont fontWithName:@"Kiro" size:18];
img.image=[UIImage imageNamed:@"logout"];
[cell addSubview:lbl];
[cell addSubview:lbln];
[cell addSubview:img];
[cell addSubview:lblLine];
}
/*
*/
// cell.backgroundColor=[UIColor whiteColor];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row==0) {
return 130;
}else if (indexPath.row==13)
{
return 70;
}else{
return 40;
}
}
не может получить ваши Ques пожалуйста, объясните более конкретно .. – vaibhav
@vaibhav вопроса является исправить UILabel обивка постион. иногда текст первой строки не устанавливался должным образом – Vinodh
@ Vinodh это правильно ... –