相关疑难解决方法(0)

如何在UIButton上只添加TOP边框?

我知道如何在iOS 7中为按钮添加边框,使用以下代码:

[[myButton layer] setBorderColor:[[[UIColor grayColor] colorWithAlphaComponent:0.5] CGColor]];
[[myButton layer] setBorderWidth:1];
[[myButton layer] setCornerRadius:15];
Run Code Online (Sandbox Code Playgroud)

但是我怎样才能添加一个边框?我想只添加顶部边框.

iphone cocoa-touch uibutton ios ios7

37
推荐指数
5
解决办法
4万
查看次数

在堆栈视图内的Uilabel之间创建垂直线

我想用Code中的自定义标头创建UICollectionView。因此,我创建了UICollectionViewCell的子类来描述我的自定义标头。我想在标题的水平线上显示五个标签。因此,我创建了五个标签并将其添加到stackView中。stackview显示我的标签被均等填充。到目前为止,一切都很完美。

标签1标签2标签3标签4标签5

   //Label 1
    let votesLabel: UILabel = {
    let label = UILabel()
    let attributedText = NSMutableAttributedString(string: "Votes", attributes: [NSFontAttributeName: UIFont.boldSystemFont(ofSize: 12) ])
    attributedText.append(NSAttributedString(string: "\n 0", attributes: [NSForegroundColorAttributeName: UIColor.lightGray, NSFontAttributeName: UIFont.systemFont(ofSize: 14)]))
    label.attributedText = attributedText

    // label.text = "11\nvotes"
    label.textAlignment = .center
    label.numberOfLines = 0
    return label
   }()


// label 2 ... 5



  // creating the subview and add the labels to my subview
        addSubview(topDividerView)
        let stackView = UIStackView(arrangedSubviews: [ votesLabel, and the other 4 labels])
       stackView.translatesAutoresizingMaskIntoConstraints = false
        stackView.axis …
Run Code Online (Sandbox Code Playgroud)

user-interface ios swift uistackview

6
推荐指数
1
解决办法
4647
查看次数

标签 统计

ios ×2

cocoa-touch ×1

ios7 ×1

iphone ×1

swift ×1

uibutton ×1

uistackview ×1

user-interface ×1