iOS 日期转String 代码类型的使用方法

来源:互联网 发布:英语四级乱序词汇软件 编辑:程序博客网 时间:2024/05/16 12:36

-(void)initDateViewNaviBar{

   /*

   self.navigationBar=[[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0,self->viewWidth , 49)];

    UINavigationItem *navigationItem=[[UINavigationItem alloc]initWithTitle:@"2014-10-29周三"];

    [self.navigationBar pushNavigationItem:navigationItem animated:YES];

    [self.view addSubview:self.navigationBar];

     */

    self.naviLabel=[[UILabelalloc]initWithFrame:CGRectMake(0,0, self->viewWidth,49)];

   NSDate *currentDate=[NSDatedate];

    NSDateFormatter *dateFormatter = [[NSDateFormatteralloc]init];

   /*

    [dateFormatter setDateFormat:@"yyyy-MM-dd e"];

    NSString *currentSysDate = [dateFormatter stringFromDate:currentDate];

     */

    [dateFormattersetDateFormat:@"yyyy-MM-dd"];

   NSString * currentSysDate=[dateFormatter stringFromDate:currentDate];

   self.naviLabel.text=currentSysDate;

    self.naviLabel.textAlignment = NSTextAlignmentCenter;

    [self.viewaddSubview:self.naviLabel];

    

}

0 0
原创粉丝点击