按钮背景图片 大小 和 位置 设置。

来源:互联网 发布:d3.js官网下载 编辑:程序博客网 时间:2024/04/30 15:05

UIButton *btnRightBar=[UIButtonbuttonWithType:UIButtonTypeSystem];

    btnRightBar.frame=CGRectMake(0,0, 30, 30);

    UIImage *image=[UIImageimageNamed:@"ic_chat_connect"];

    image=[image stretchableImageWithLeftCapWidth:floorf(20)topCapHeight:20];

    [btnRightBar setBackgroundImage:imageforState:UIControlStateNormal];

    btnRightBar.contentEdgeInsets=UIEdgeInsetsMake(5,5, 5, 5);

    [btnRightBar addTarget:self action:@selector(rightItemAction) forControlEvents:UIControlEventTouchUpInside];

    btnRightBar.backgroundColor=[UIColorredColor];

    self.navigationItem.rightBarButtonItem=[[UIBarButtonItemalloc] initWithCustomView:btnRightBar];

0 0
原创粉丝点击