Skip to content

Instantly share code, notes, and snippets.

@winwu
Created May 13, 2014 16:14
Show Gist options
  • Save winwu/7387c225a826302eabd5 to your computer and use it in GitHub Desktop.
Save winwu/7387c225a826302eabd5 to your computer and use it in GitHub Desktop.
如何用程式顯示 ios facebook status, name profile picture
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = NSLocalizedString(@"Menu", nil);
self.menus = @[@"My Account", @"Menu 2", @"Menu 3", @"Menu 4"];
[self.view addSubview: self.nameLabel];
[self.view addSubview: self.statusLabel];
[self.view addSubview: self.profilePictureView];
}
- (UILabel *)nameLabel
{
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 30)];
_nameLabel.backgroundColor = [UIColor grayColor];
_nameLabel.textColor = [UIColor blackColor];
_nameLabel.textAlignment = NSTextAlignmentLeft;
_nameLabel.text = @"";
_nameLabel.clipsToBounds = YES;
}
return _nameLabel;
}
-(UILabel *)statusLabel
{
if(!_statusLabel){
_statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 60, 200, 30)];
_statusLabel.backgroundColor = [UIColor grayColor];
_statusLabel.textColor = [UIColor blackColor];
_statusLabel.textAlignment = NSTextAlignmentLeft;
_statusLabel.text = @"";
_statusLabel.clipsToBounds = YES;
}
return _statusLabel;
}
-(FBProfilePictureView *)profilePictureView
{
if(!_profilePictureView){
//這裡一定要放在 if, 否則會要不到圖片, 應該是因為沒有放 if 就變成重新 init 一次 FBProfilePictureView
_profilePictureView = [[FBProfilePictureView alloc] initWithFrame:CGRectMake(10, 60, 60, 60)];
}
return _profilePictureView;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment