這裏是我的代碼,這是可能的,通過顏色的數組中的UIImageView邊框的顏色
cell.imagename.image=[ColorsArray objectAtIndex:indexPath.row].CGColor;
這裏是我的代碼,這是可能的,通過顏色的數組中的UIImageView邊框的顏色
cell.imagename.image=[ColorsArray objectAtIndex:indexPath.row].CGColor;
我從你的代碼猜測imagename
是UIImageView
。如果是這樣,我認爲你正在尋找這個代碼。 objectAtIndex:
將返回id
,因此您需要將其轉換爲UIColor
才能使用.CGColor
屬性。
UIColor *borderColor = (UIColor *)[ColorsArray objectAtIndex:indexPath.row]
cell.imagename.layer.borderColor = borderColor.CGColor;
試過但是,屬性找不到對象的類型'id'這個錯誤顯示 – Preetha
更新了我的答案。 – keithbhunter
更新代碼中不需要強制轉換。 – rmaddy