ios - 请问这种带尖角的view有什么好的实现方法
伊谢尔伦
伊谢尔伦 2017-04-18 09:49:55
0
8
1269

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(8)
伊谢尔伦

The programmer’s solution is to create a square view; the background color is the same as the main frame color. Then; rotate this square view 90 degrees. Add to main box. Just specify the location. In other words, this style is made up of two views.

左手右手慢动作

Make a bubble image, and then put a tableView in it. After setting the fixed constraints and slicing of the image, can you try this? ?

伊谢尔伦

You can draw one, which saves cutting resources, is more efficient, and is easy to reuse.

- (UIView *)arrowView{
    if (!_arrowView) {
        // draw
        CGSize size = CGSizeMake(kDefaultArrowWeight, kDefaultArrowHeight);
        UIBezierPath *path = [[UIBezierPath alloc] init];
        [path moveToPoint:CGPointMake(size.width / 2.0, 0)];
        [path addLineToPoint:CGPointMake(0, size.height)];
        [path addLineToPoint:CGPointMake(size.width, size.height)];
        path.lineWidth = 1.0;
        
        CAShapeLayer *arrowLayer = [CAShapeLayer layer];
        arrowLayer.path = path.CGPath;
        
        _arrowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
        _arrowView.layer.mask = arrowLayer;
        _arrowView.backgroundColor = self.contentViewBackgroundColor;
    }
    return _arrowView;
}
PHPzhong

A triangular imageview is attached to the UIView, and a tableview is attached to it. There is no problem with scrolling like this, and there is no problem if you want to adjust the position of the imageView.

小葫芦

HTML:

<p class="test_triangle_border">
    <a href="#">三角形</a>
    <p class="popup">
        <span><em></em></span>测试
    </p>
</p>

 

CSS:

.test_triangle_border{
    width:200px;
    margin:0 auto 20px;
    position:relative;
}
.test_triangle_border a{
    color:#333;
    font-weight:bold;
    text-decoration:none;
}
.test_triangle_border .popup{
    width:100px;
    background:#cf0;
    padding:10px 20px;
    color:#333;
    border-radius:4px;
    position:absolute;
    top:30px;
    left:30px;
    border:1px solid #333;
}
.test_triangle_border .popup span{
    display:block;
    width:0;
    height:0;
    border-width:0 10px 10px;
    border-style:solid;
    border-color:transparent transparent #333;
    position:absolute;
    top:-10px;
    left:50%;/* 三角形居中显示 */
    margin-left:-10px;/* 三角形居中显示 */
}
.test_triangle_border .popup em{
    display:block;
    width:0;
    height:0;
    border-width:0 10px 10px;
    border-style:solid;
    border-color:transparent transparent #cf0;
    position:absolute;
    top:1px;
    left:-10px;
}

This is an answer I have given to others, please change it according to your needs

刘奇

This is a control, exclusive for iPad. It’s called UIPopoverController.

阿神

If it is iOS8, you can use UIPopoverPresentationController

Peter_Zhu

The artist needs a picture to solve

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!