Update the constant of a constraint programmatically in Swift

self.view.layoutIfNeeded()
UIView.animateWithDuration(1, animations: {
self.sampleConstraint.constant = 20
self.view.layoutIfNeeded()
})

add action to image textfield

searchControl.backgroundColor = UIColor.whiteColor()
searchControl.placeholder = "Search item ..."
searchControl.font = UIFont.systemFontOfSize(14)
searchControl.contentVerticalAlignment = UIControlContentVerticalAlignment.Center
searchControl.rightViewMode = UITextFieldViewMode.Always;
searchControl.clearButtonMode = UITextFieldViewMode.Always;
let zoomGlass = UIImageView(image: UIImage(named: "search"))

remove in dictionary

imageAvata = params["avatar"] as! UIImageView
imagecover = params["cover"] as! UIImageView
if let aDictionaryIndex = params.indexForKey("avatar") {
// This will remove the key/value pair from the dictionary and return it as a tuple pair.
let (key, value) = params.removeAtIndex(aDictionaryIndex)
print(key) // anotherKey
print(value) // bar
}
if let aDictionaryIndex = params.indexForKey("cover") {

Didsable select cell

cell.selectionStyle = .None

Folder structure

Đôi khi upload lên Appstore bị lỗi

Đôi khi upload lên Appstore bị lỗi
thì nếu chưa tìm được ra cách khắc phục thì ta dùng "application uploader".

format NSdate

let monthName = NSDateFormatter().shortMonthSymbols[monthNumber - 1]

snp_makeConstraints

dequeCell.button4.snp_makeConstraints(closure: { (make) in
make.width.equalTo(getScaleByStatus(state[3]) * length)
})

Swipe to delete cell causes tableViewHeader to move with cell

func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell : SectionOrderCell = tableView.dequeueReusableCellWithIdentifier("SectionOrderCell") as! SectionOrderCell
if section == 0 {
cell.statelabel.text = "PAID".localized()
} else if section == 1 {
cell.statelabel.text = "UNPAID".localized()
}
return cell.contentView
}

Swift: Could not cast value of type '__NSCFArray' to 'NSDictionary'

let weather = mainDictionary["weather"] as! [[String : AnyObject]]

Pages

Subscribe to Trần Mạnh Hoàng RSS