objective-c - 创建硬自定义按钮

标签 objective-c ios uibutton

我不知道如何构造这个按钮。我在创建这个时需要帮助,请注意当按钮处于事件状态时不会绘制 strip 。我应该使用哪些元素?

在链接上你可以看到这个按钮

http://i.stack.imgur.com/0mmJ0.png

    UIButton *clone = [[UIButton alloc] initWithFrame:frame];
    [clone setTitle:strDate forState:UIControlStateNormal];
    [clone setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
    clone.frame = CGRectMake(19, post_offer_top*(i-1)+22, 281, 75);
    clone.tag = my_id;
   // [clone setTitle:[[buttons objectAtIndex:i-1] objectForKey:@"title"] forState:UIControlStateNormal];
    clone.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    clone.contentEdgeInsets = UIEdgeInsetsMake(44, 31, 0, 0);
    [clone setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [clone setTitleShadowColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [clone.titleLabel setFont:[UIFont fontWithName:@"PF DinDisplay Pro" size:10]];
    [clone.titleLabel setShadowOffset:CGSizeMake(0.0f, 1.0f)];

有什么想法吗?

最佳答案

你应该像这样初始化按钮 [UIButton buttonWithType:UIButtonTypeCustom]

关于objective-c - 创建硬自定义按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13048965/

相关文章:

ios - TableView 从 : numberOfRowsInSection 中的最后一部分开始

ios - 使用下一个和上一个UIButton切换UITextView/UILabel中的不同文本

c++ - Iphone、回调和 objective-c

ios - iOS 控制中心是否调用任何 UIApplication 方法。?

objective-c - Objective-C : Start Point and End Point

ios - Crashlytics - 为什么我需要在上传 dSYM 之前下载它们?

ios - 将 int 变量传递到新的 View Controller (在代码中)- Objective C - Xcode

ios - 为什么 SCNNode.presentation.position 相对较慢,有解决方法吗?

iphone - 显示自定义 UIButton 上的灰色叠加层

ios - 更改 UIButton 中标题的背景颜色