UITableViewCellの選択色を変える場合はUITableViewCellのカスタムクラスを作成し、init内などで以下のような記述をするのが一般的だと思います。 UIView *selectedBackgroundView = [[UIView alloc] init]; selectedBackgroundView.backgroundColor = [UIColor yellowColor]; self.selectedBackgroundView = selectedBackgroundView; UIView *v = [[UIView alloc] initWithFrame:CGRectMake(40, 0, 1, 40)]; v.backgroundColor = [UIColor blackColor]; // ←selectedにしたときに黒い色が消えてしまう
![UITableViewCellの選択色を設定した場合にsubviewが消えてしまう場合の対処法 - Qiita](https://cdn-ak-scissors.b.st-hatena.com/image/square/70213cc38dd6bb1f4d9e379fec3b4201abc3c5e6/height=288;version=1;width=512/https%3A%2F%2Fqiita-user-contents.imgix.net%2Fhttps%253A%252F%252Fcdn.qiita.com%252Fassets%252Fpublic%252Farticle-ogp-background-9f5428127621718a910c8b63951390ad.png%3Fixlib%3Drb-4.0.0%26w%3D1200%26mark64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZ3PTkxNiZoPTMzNiZ0eHQ9VUlUYWJsZVZpZXdDZWxsJUUzJTgxJUFFJUU5JTgxJUI4JUU2JThBJTlFJUU4JTg5JUIyJUUzJTgyJTkyJUU4JUE4JUFEJUU1JUFFJTlBJUUzJTgxJTk3JUUzJTgxJTlGJUU1JUEwJUI0JUU1JTkwJTg4JUUzJTgxJUFCc3VidmlldyVFMyU4MSU4QyVFNiVCNiU4OCVFMyU4MSU4OCVFMyU4MSVBNiVFMyU4MSU5NyVFMyU4MSVCRSVFMyU4MSU4NiVFNSVBMCVCNCVFNSU5MCU4OCVFMyU4MSVBRSVFNSVBRiVCRSVFNSU4NyVBNiVFNiVCMyU5NSZ0eHQtY29sb3I9JTIzMjEyMTIxJnR4dC1mb250PUhpcmFnaW5vJTIwU2FucyUyMFc2JnR4dC1zaXplPTU2JnR4dC1jbGlwPWVsbGlwc2lzJnR4dC1hbGlnbj1sZWZ0JTJDdG9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