ALGridView 是使用 Swift 编写的简单网格视图。
//-- Full initializer (passing margins, padding) let frame = CGRect(x: 10.0, y: 10.0, width: 200.0, height: 200.0) let margins = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) let gridView = GridView(frame: frame, columns: 3, rows: 3, margins: margins, padding: 10) { column, row, contentView in let view = UIView(frame: contentView.bounds) view.backgroundColor = UIColor.blueColor() contentView.addView(view) } someView.addSubview(gridView) //-- Simplified initializer (frame, columns, rows and constructor closure) let gridView = GridView(frame: frame, columns: 3, rows: 3) { column, row, contentView in //.. constructor code