UITableView 编辑模式左边图标的替换
2015-08-23 00:00
766 查看
摘要: 替换UITableVeiw编辑模式左边系统图标
在自定义的cell类中,添加
swift:
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
if self.editing {
for (var control) in self.subviews {
if control.isMemberOfClass(NSClassFromString("UITableViewCellEditControl")) {
control = control as! UIControl
if selected {
(control.subviews.last as! UIImageView).image = UIImage(named: "compass")
} else {
control.layer.backgroundColor = self.backgroundColor?.CGColor
}
}
}
}
}
oc:
在自定义的cell类中,添加
swift:
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
if self.editing {
for (var control) in self.subviews {
if control.isMemberOfClass(NSClassFromString("UITableViewCellEditControl")) {
control = control as! UIControl
if selected {
(control.subviews.last as! UIImageView).image = UIImage(named: "compass")
} else {
control.layer.backgroundColor = self.backgroundColor?.CGColor
}
}
}
}
}
oc:
- (
void
)setSelected:(
BOOL
)selected animated:(
BOOL
)animated
{
[
super
setSelected:selected animated:animated];
if
(![
self
.viewcontroller isEditing]) {
self
.selectionStyle = UITableViewCellSelectionStyleNone;
}
else
{
self
.selectionStyle = UITableViewCellSelectionStyleBlue;
//Bug fix: 第一次点击cell的左侧的复选框无法选中
//手动增加edit control的处理
for
(UIControl *control in
self
.subviews){
if
([control isMemberOfClass:
NSClassFromString
(@
"UITableViewCellEditControl"
)]){
[control setSelected:selected];
if
(selected) {
[control setBackgroundColor:[UIColor colorWithRed:0.91f green:0.94f blue:0.98f alpha:1.00f]];
}
else
{
[control setBackgroundColor:
self
.backgroundColor];
}
}
}
}
}
相关文章推荐
- POJ 2533 Longest Ordered Subsequence
- poj 3581 Sequence(后缀数组)
- Codeforces 570D TREE REQUESTS dfs序+树状数组 异或
- 声明UI控件为什么用weak?
- Failed to sync Gradle project '项目名称(module)' Error:failed to find Build Tools revision 20.0.0
- hue安装与部署
- hue安装与部署
- hue安装与部署
- hue安装与部署
- leetCode 115.Distinct Subsequences(子序列距离) 解题思路和方法
- CSU1207(Strictly-increasing sequence)
- PAT 1017. Queueing at Bank (25)
- JavaSE复习日记 : 循环终止语句(break/break outerFor/continue)
- IOS UI TabBar标签栏的使用
- 工厂模式和builder模式的区别
- 阿里14年机试-----在text中找出以同样的顺序连续出现在query中的最长连续字母序列的长度
- Android GUI之Window、WindowManager
- IOS UI UIScrollView+UIPageControl组合使用
- SUID + SGID + STICKY
- poj 2031 Building a Space Station【最小生成树】